Skip to content

Commit

Permalink
Revert "version bump (#52)"
Browse files Browse the repository at this point in the history
This reverts commit 6f76fc1.
  • Loading branch information
spiceywasabi committed Nov 14, 2023
1 parent a48f0f8 commit d16d74b
Show file tree
Hide file tree
Showing 16 changed files with 1,764 additions and 149 deletions.
1,427 changes: 1,427 additions & 0 deletions css/bootstrap-icons.css

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions css/bootstrap-utilities.min.css

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions css/bootstrap-utilities.min.css.map

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions css/bootstrap.min.css

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions css/bootstrap.min.css.map

Large diffs are not rendered by default.

File renamed without changes.
19 changes: 0 additions & 19 deletions core/style.css → css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -171,25 +171,6 @@ button.fancy:hover::after {
color: #000;
}

#release-notes {
max-width: 100%;
text-align: left;
font-family: pt-mono, monospace;
font-style: normal;
font-weight: 400;
height: 256px;
font-size: 16px;
overflow-x: hidden;
overflow-x: auto;
transition : color 0.1s linear;
padding: 0 20px;
border: 20px solid #eee;
-ms-overflow-style: none;
scrollbar-width: none;
background-color: #eee;
color: #000;
}


.accordion-details {
padding: 8px 8px;
Expand Down
277 changes: 277 additions & 0 deletions extras/stubgen.py

Large diffs are not rendered by default.

47 changes: 13 additions & 34 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
<meta content="O.MG" name="author">
<title> O.MG Web Flasher </title>
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="core/style.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<link href="https://fonts.gstatic.com" rel="preconnect">
<!-- icons -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.2.2/font/bootstrap-icons.css">
<!--<link href="assets/icons/icon-57x57.png" rel="apple-touch-icon" sizes="57x57">
<link href="assets/icons/icon-60x60.png" rel="apple-touch-icon" sizes="60x60">-->
<link href="assets/icons/icon-72x72.png" rel="apple-touch-icon" sizes="72x72">
Expand Down Expand Up @@ -39,9 +39,9 @@
}
</script>
<!-- import the webpage's javascript file -->
<script src="core/utilities.js" defer></script>
<script src="core/esptool.js" defer></script>
<script src="core/script.js" defer></script>
<script src="js/utilities.js" defer></script>
<script src="js/esptool.js" defer></script>
<script src="js/script.js" defer></script>
</head>
<body>
<!-- CONTAINER -->
Expand Down Expand Up @@ -232,15 +232,13 @@ <h2 class="accordion-header" id="programmerStep3">
<div id="programmerStep3-collapse" class="accordion-collapse collapse show" aria-labelledby="programmerStep2">
<div class="accordion-body">
Press the <strong>Program</strong> button below, thats it! Just wait for the progress bar to complete.

<div class="pb-2 pt-3 justify-content-center text-center">
<div><label for="branch" class="form-label">Firmware Build</label></div>
<div class="d-inline-flex gap-2">
<select id="branch" class="form-select form-select-lg">
<option value="stable" selected>(Stable) [Default]</option>
</select>
<button type="button" class="btn btn-dark btn-lg fancy" id="btnReleaseNotes" data-bs-toggle="modal" data-bs-target="#modalReleaseNotes">Release Notes</button>
</div>
<label for="branch" class="form-label">Firmware Build</label>
<select id="branch" class="form-select">
<option value="stable" selected>v2.5 (Stable) [Default]</option>
<option value="beta">v3.0 (Beta)</option>
<option value="legacy-v2.0">v2.0 (Legacy)</option>
</select>
</div>
<div class="pb-2 pt-3 justify-content-center text-center">
<div class="progress">
Expand Down Expand Up @@ -286,9 +284,9 @@ <h3 class="display-6" id="success-notification">Success!</h3>
<div>

<p class="lead text-center" id="success-msg">
To use the O.MG Cable: Plug the cable into a USB port.
To use the O.MG Cable: Plug the cable into a USB port.
Then connect to the WiFi network and browse to http://192.168.4.1/.
<br/>For additional instructions, please go <a href="https://github.com/O-MG/O.MG_Cable-Firmware/wiki">here</a>.
<br/>For additional instructions, please go <a href=" https://github.com/O-MG/O.MG_Cable-Firmware/wiki">here</a>.
</p>
<p class="d-none text-center" id="success-state-msg">
Further details can be seen in the console and corresponding log from the flasher log button in the top right of the interface
Expand Down Expand Up @@ -326,25 +324,6 @@ <h5 class="modal-title">Web Flasher Console</h5>
</div>
</div>
</div>
<div class="modal fade" id="modalReleaseNotes" tabindex="-1" aria-labelledby="modalReleaseNotes" aria-hidden="true">
<div class="modal-dialog modal-xl modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="release-notes-modal-title">Release Notes</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div class="font-weight-light p-2">
<p id="release-notes-modal-intro">The following are the release notes for the selected version of O.MG Unified Firmware</p>
</div>
<div class="pt-2" id="release-notes">Not Found...</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="modalSettings" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="modalSettings" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
Expand Down
7 changes: 7 additions & 0 deletions js/bootstrap.bundle.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions js/bootstrap.bundle.min.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions js/bootstrap.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/bootstrap.min.js.map

Large diffs are not rendered by default.

23 changes: 12 additions & 11 deletions core/esptool.js → js/esptool.js
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ class EspLoader {
* Opens a Web Serial connection to a micro:bit and sets up the input and
* output stream.
*/
async connect(tries=5) {
async connect() {
// - Request a port and open a connection.
const filter = { usbVendorId: 0x10c4 };
var filters = []
Expand All @@ -395,8 +395,11 @@ class EspLoader {

const signals = await port.getSignals();

this.logMsg("Serial connection opened...")
this.logMsg("Connected successfully.")

this.logMsg("Try to reset.")
await this.hardReset(true);

outputStream = port.writable;
inputStream = port.readable;
}
Expand Down Expand Up @@ -614,8 +617,8 @@ class EspLoader {
* Put into ROM bootload mode & attempt to synchronize with the
* ESP ROM bootloader, we will retry a few times
*/
async sync(syncCount=3) {
for (let i = 0; i < syncCount; i++) {
async sync() {
for (let i = 0; i < 5; i++) {
inputBuffer = []
let response = await this._sync();
if (response) {
Expand All @@ -624,8 +627,8 @@ class EspLoader {
}
await this.sleep(100);
}
return false;
//throw("Couldn't sync to O.MG Device. Try unplugging & replugging the programmer and try again.");

throw("Couldn't sync to O.MG Device. Try unplugging & replugging the programmer and try again.");
};

/**
Expand Down Expand Up @@ -896,18 +899,18 @@ class EspLoader {
}
}

async reset(r = false, baseTimeout=500, timeoutMultiplier=1) {
async hardReset(r = false) {
logMsg("Trying Serial Reset....")
await port.setSignals({
dataTerminalReady: false,
requestToSend: true,
});
await new Promise((resolve) => setTimeout(resolve, baseTimeout*timeoutMultiplier));
await new Promise((resolve) => setTimeout(resolve, 500));
await port.setSignals({
dataTerminalReady: r,
requestToSend: false,
});
await new Promise((resolve) => setTimeout(resolve, baseTimeout));
await new Promise((resolve) => setTimeout(resolve, 1500));
}

async getStubCode() {
Expand Down Expand Up @@ -973,8 +976,6 @@ class EspLoader {
}
}
this.logMsg("Running stub...")
console.log("stub loaded")
console.log(stub)
await this.memFinish(stub['entry']);

let p = await this.readBuffer(500);
Expand Down
88 changes: 10 additions & 78 deletions core/script.js → js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
var espTool;

const baudRates = [115200];
const connectionBaseDelay = 500;
const connectionAttempts = 4;
const bufferSize = 512;
const eraseFillByte = 0x00;

Expand Down Expand Up @@ -48,7 +46,6 @@ const statusStep1 = document.getElementById("programmerStep1-status");
const statusStep2 = document.getElementById("programmerStep2-status");
const statusStep3 = document.getElementById("programmerStep3-status");
const butHardware = document.getElementById("btnConnectHw");
const butReleaseNotes = document.getElementById("btnReleaseNotes");
const butProgram = document.getElementById("btnProgram");

const progress = document.querySelectorAll(".progress-bar");
Expand Down Expand Up @@ -83,8 +80,6 @@ var settings = {
"skipWelcome": butSkipWelcome
}

var releaseDataCache = {}

const url_memmap = "assets/memmap.json";
const url_releases = "https://api.github.com/repos/O-MG/O.MG-Firmware/releases?per_page=100"; // move to proper spot later.
const url_branches = "https://api.github.com/repos/O-MG/O.MG-Firmware/branches";
Expand Down Expand Up @@ -124,7 +119,7 @@ document.addEventListener("DOMContentLoaded", () => {
}

let urlloc = String(window.location.href);
if(urlloc.includes("localhost")|| urlloc.includes("127.0.0.1") || urlloc.includes("Test")){
if(urlloc.includes("localhost") || urlloc.includes("Test")){
debugState=true;
skipWelcome=false;
toggleDevConf(true);
Expand Down Expand Up @@ -199,7 +194,6 @@ document.addEventListener("DOMContentLoaded", () => {
butDiagnosticFirmware.addEventListener("click",toggleDiagnostics)
butHardware.addEventListener("click", clickHardware);
butProgram.addEventListener("click", clickProgramErase);
butReleaseNotes.addEventListener("click",clickReleaseNotes)
butDownload.addEventListener("click", clickDownload);
butClear.addEventListener("click", clickClear);
autoscroll.addEventListener("click", clickAutoscroll);
Expand Down Expand Up @@ -263,12 +257,10 @@ async function fetchWithRetry(url, options = {}, maxRetries = 3, retryDelay = 10

async function connect() {
logMsg("Connecting...")
let synced = await espTool.connect()
await espTool.connect()
readLoop().catch((error) => {
toggleUIConnected(false);
return false
});
return synced
}

function initBaudRate() {
Expand Down Expand Up @@ -529,30 +521,14 @@ async function clickConnect() {
}
butConnect.textContent = " Connecting";
butConnect.insertAdjacentHTML('afterbegin', '<span class="spinner-border spinner-border-sm"></span> ');

let sync_status = false;
await connect();
for(let i=0;i<connectionAttempts;i++){
let delay = (i+1)*connectionBaseDelay;
logMsg("Trying to initiate connection with O.MG Device...")
await espTool.reset(true,delay);
sync_status = await espTool.sync();
console.log(sync_status)
if(sync_status){
logMsg("Obtained synchronization with O.MG Device")
break;
} else {
logMsg("Failed to connect to O.MG Device, lost synchronization. Resetting connection after "+delay+" ms.")
}
}
try {
if (sync_status) {
if (await espTool.sync()) {
toggleUIConnected(true);
let baud = parseInt(baudRate.value);
// get our chip info
logMsg("Connected to O.MG Device")
logMsg("Connected to " + await espTool.chipName());
if (debugState) {
logMsg("Connected to " + await espTool.chipName());
console.log(espTool);
}
logMsg("MAC Address: " + formatMacAddr(espTool.macAddr()));
Expand All @@ -571,7 +547,11 @@ async function clickConnect() {
await espTool.chipName();
// and proceed
if (baud != ESP_ROM_BAUD) {
await changeBaudRate(baud);
if (await espTool.chipType() == ESP32) {
logMsg("WARNING: ESP32 is having issues working at speeds faster than 115200. Continuing at 115200 for now...")
} else {
await changeBaudRate(baud);
}
}
}
isConnected = true;
Expand Down Expand Up @@ -620,46 +600,6 @@ async function clickDarkMode() {
//saveSetting("darkmode", darkMode.checked);
}

async function clickReleaseNotes(){
let selected_version = butBranch.value;
let display_text = selected_version;
try {
let display_text = butBranch.options[butBranch.selectedIndex].text;
} catch(error) {
console.log(error);
}
let intro_element = document.getElementById("release-notes-modal-intro");
let title_element = document.getElementById("release-notes-modal-title");
let notes_element = document.getElementById("release-notes");

let title_value = "Release Notes for " + selected_version;
let intro_value = "Version release notes for the O.MG Unified Firmware version " + display_text + "."

intro_element.textContent = intro_value;
title_element.textContent = title_value;

let release_notes = "<p>Unable to read release notes data...</p>"
let releases = Object.keys(releaseDataCache)
if(releases.length>=1){
for(let release_name in releaseDataCache){
if(release_name.includes(selected_version,0)){
let reldata = releaseDataCache[release_name]
if(debugState){
console.log("Found potential match for: " + release_name);
console.log(reldata);
}
if("body" in reldata){
release_notes = "<p>";
release_notes += reldata["body"].replace(/\\r|\r/g,"").replace(/\\n|\n/g, '<br>\n');
release_notes += "</p>\r\n";
}
}
}
}
notes_element.innerHTML = release_notes
console.log("I've been called.");
}

async function getDiagnosticFirmwareFiles(erase = false, bytes = 0x00) {

const readUploadedFileAsArrayBuffer = (inputFile) => {
Expand Down Expand Up @@ -829,12 +769,6 @@ async function buildReleaseSelectors(dr=["beta","stable"]){
}
}
}
// set the cache
if(debugState){
console.log("setting release cache for user");
console.log(releases);
}
releaseDataCache = releases;
// reset our list
butBranch.innerHTML="";
// get our defaults
Expand All @@ -852,7 +786,6 @@ async function buildReleaseSelectors(dr=["beta","stable"]){
// ADD DEBUG IF
console.log("Adding a new release " + dr_str + " with tag " + dr_tag);
console.log(dr);
releaseDataCache[dr_tag]=releases[dr[i]];
butBranch.options.add(new Option(dr_str, dr_tag,no_default,no_default));
}
delete(releases[dr[i]]);
Expand All @@ -863,10 +796,8 @@ async function buildReleaseSelectors(dr=["beta","stable"]){
if(debugState){
console.log(details);
}
releaseDataCache[details["tag_name"]]=details;
butBranch.options.add(new Option(details["name"], details["tag_name"],no_default,no_default));
}

}

async function getFirmwareFiles(branch, erase = false, bytes = 0x00) {
Expand Down Expand Up @@ -1721,6 +1652,7 @@ function saveSettings() {

}


function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
File renamed without changes.

0 comments on commit d16d74b

Please sign in to comment.