Skip to content

Commit 5d3ed84

Browse files
makermelissagithub-actions[bot]
authored andcommitted
Github Action: Updated dist files
1 parent 31cb17d commit 5d3ed84

File tree

4 files changed

+135
-92
lines changed

4 files changed

+135
-92
lines changed

dist/base_installer.js

Lines changed: 66 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
'use strict';
66
import {html, render} from 'https://cdn.jsdelivr.net/npm/lit-html/+esm';
77
import {asyncAppend} from 'https://cdn.jsdelivr.net/npm/lit-html/directives/async-append/+esm';
8-
import * as esptoolPackage from "https://cdn.jsdelivr.net/npm/esp-web-flasher@5.1.2/dist/web/index.js/+esm"
9-
8+
import { ESPLoader, Transport } from "https://unpkg.com/esptool-js@0.5.3/bundle.js";
109
export const ESP_ROM_BAUD = 115200;
1110

1211
export class InstallButton extends HTMLButtonElement {
@@ -15,12 +14,15 @@ export class InstallButton extends HTMLButtonElement {
1514

1615
constructor() {
1716
super();
17+
this.baudRate = ESP_ROM_BAUD;
1818
this.dialogElements = {};
1919
this.currentFlow = null;
2020
this.currentStep = 0;
2121
this.currentDialogElement = null;
22-
this.port = null;
23-
this.espStub = null;
22+
this.device = null;
23+
this.transport = null;
24+
this.esploader = null;
25+
this.chip = null;
2426
this.dialogCssClass = "install-dialog";
2527
this.connected = this.connectionStates.DISCONNECTED;
2628
this.menuTitle = "Installer Menu";
@@ -343,13 +345,17 @@ export class InstallButton extends HTMLButtonElement {
343345
return macAddr.map((value) => value.toString(16).toUpperCase().padStart(2, "0")).join(":");
344346
}
345347

346-
async disconnect() {
347-
if (this.espStub) {
348-
await espStub.disconnect();
349-
await espStub.port.close();
350-
this.updateUIConnected(this.connectionStates.DISCONNECTED);
351-
this.espStub = null;
348+
async espDisconnect() {
349+
if (this.transport) {
350+
await this.transport.disconnect();
351+
await this.transport.waitForUnlock(1500);
352+
this.updateEspConnected(this.connectionStates.DISCONNECTED);
353+
this.transport = null;
354+
this.device = null;
355+
this.chip = null;
356+
return true;
352357
}
358+
return false;
353359
}
354360

355361
async runFlow(flow) {
@@ -390,6 +396,17 @@ export class InstallButton extends HTMLButtonElement {
390396
}
391397
}
392398

399+
async advanceSteps(stepCount) {
400+
if (!this.currentFlow) {
401+
return;
402+
}
403+
404+
if (this.currentStep <= this.currentFlow.steps.length + stepCount) {
405+
this.currentStep += stepCount;
406+
await this.currentFlow.steps[this.currentStep].bind(this)();
407+
}
408+
}
409+
393410
async showMenu() {
394411
// Display Menu
395412
this.showDialog(this.dialogs.menu);
@@ -405,38 +422,60 @@ export class InstallButton extends HTMLButtonElement {
405422
this.showDialog(this.dialogs.error, {message: message});
406423
}
407424

408-
async setBaudRateIfChipSupports(chipType, baud) {
409-
if (baud == ESP_ROM_BAUD) { return } // already the default
410-
411-
if (chipType == esptoolPackage.CHIP_FAMILY_ESP32) { // only supports the default
412-
this.logMsg(`ESP32 Chip only works at 115200 instead of the preferred ${baud}. Staying at 115200...`);
413-
return
414-
}
425+
async setBaudRateIfChipSupports(baud) {
426+
if (baud == this.baudRate) { return } // already the current setting
415427

416428
await this.changeBaudRate(baud);
417429
}
418430

419431
async changeBaudRate(baud) {
420-
if (this.espStub && this.baudRates.includes(baud)) {
421-
await this.espStub.setBaudrate(baud);
432+
if (this.baudRates.includes(baud)) {
433+
if (this.transport == null) {
434+
this.baudRate = baud;
435+
} else {
436+
this.errorMsg("Cannot change baud rate while connected.");
437+
}
422438
}
423439
}
424440

425-
async espHardReset(bootloader = false) {
426-
if (this.espStub) {
427-
await this.espStub.hardReset(bootloader);
441+
async espHardReset() {
442+
if (this.esploader) {
443+
await this.esploader.hardReset();
428444
}
429445
}
430446

431447
async espConnect(logger) {
432-
// - Request a port and open a connection.
433-
this.port = await navigator.serial.requestPort();
434-
435448
logger.log("Connecting...");
436-
await this.port.open({ baudRate: ESP_ROM_BAUD });
449+
450+
if (this.device === null) {
451+
this.device = await navigator.serial.requestPort({});
452+
this.transport = new Transport(this.device, true);
453+
}
454+
455+
const espLoaderTerminal = {
456+
clean() {
457+
// Clear the terminal
458+
},
459+
writeLine(data) {
460+
logger.log(data);
461+
},
462+
write(data) {
463+
logger.log(data);
464+
},
465+
};
466+
467+
const loaderOptions = {
468+
transport: this.transport,
469+
baudrate: this.baudRate,
470+
terminal: espLoaderTerminal,
471+
debugLogging: false,
472+
};
473+
474+
this.esploader = new ESPLoader(loaderOptions);
475+
this.chip = await this.esploader.main();
437476

438477
logger.log("Connected successfully.");
439478

440-
return new esptoolPackage.ESPLoader(this.port, logger);
479+
return this.esploader;
441480
};
442481
}

dist/base_installer.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)