Skip to content

Commit e4ee7bd

Browse files
authored
Merge pull request #314 from circuitpython/beta
Add the current Beta features to Main
2 parents 82dd08e + 29f5c08 commit e4ee7bd

21 files changed

+1711
-1141
lines changed

images/checkmark.svg

Lines changed: 1 addition & 0 deletions
Loading

index.html

Lines changed: 71 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,21 @@
9797
<div id="serial-bar">
9898
<button class="purple-button btn-restart">Restart<i class="fa-solid fa-redo"></i></button>
9999
<button class="purple-button btn-clear">Clear<i class="fa-solid fa-broom"></i></button>
100+
<button class="purple-button btn-plotter">Plotter<i class="fa-solid fa-chart-line"></i></button>
100101
<div id="terminal-title"></div>
101102
</div>
103+
<div id="plotter" class="hidden">
104+
<label for="buffer-size">Buffer Size</label>
105+
<input type="number" id="buffer-size" value="20">
106+
<label for="plot-gridlines-select">Grid Lines</label>
107+
<select id="plot-gridlines-select">
108+
<option value="both">Both</option>
109+
<option value="x">X Only</option>
110+
<option value="y">Y Only</option>
111+
<option value="none">None</option>
112+
</select>
113+
<canvas id="plotter-canvas"></canvas>
114+
</div>
102115
<div id="terminal"></div>
103116
</div>
104117
</div>
@@ -199,7 +212,9 @@ <h1>Web Bluetooth not available!</h1>
199212
flag. However be careful as it would be risky to browse the web with this flag turned
200213
on as it enables many other experimental web platform features. Starting with Chromium
201214
version 100, enable the <a href="about://flags/#enable-web-bluetooth">about://flags/#enable-web-bluetooth</a>
202-
safer flag instead.</p>
215+
safer flag instead. You can also enable Web Bluetooth Binding by enabling the
216+
<a href="about://flags/#enable-web-bluetooth-new-permissions-backend">about://flags/#enable-web-bluetooth-new-permissions-backend</a>
217+
flag instead of the experimental features if it is available.</p>
203218
</div>
204219
</section>
205220
<section class="step">
@@ -325,6 +340,22 @@ <h1>Select USB Host Folder</h1>
325340
<td>IP Address:</td>
326341
<td><a id="ip"></a></td>
327342
</tr>
343+
<tr>
344+
<td>Build Date:</td>
345+
<td><span id="builddate"></span></td>
346+
</tr>
347+
<tr>
348+
<td>MCU Name:</td>
349+
<td><span id="mcuname"></span></td>
350+
</tr>
351+
<tr>
352+
<td>Board ID:</td>
353+
<td><span id="boardid"></span></td>
354+
</tr>
355+
<tr>
356+
<td>UID:</td>
357+
<td><span id="uid"></span></td>
358+
</tr>
328359
</tbody>
329360
</table>
330361
<h3>More network devices<i class="refresh fa-solid fa-sync-alt" title="Refresh Device List"></i></h3>
@@ -333,6 +364,45 @@ <h3>More network devices<i class="refresh fa-solid fa-sync-alt" title="Refresh D
333364
<button class="purple-button ok-button">Close</button>
334365
</div>
335366
</div>
367+
<div class="popup-modal shadow closable" data-popup-modal="device-info">
368+
<i class="fa-solid fa-2x fa-xmark text-white bg-primary p-3 popup-modal__close"></i>
369+
<table class="device-info">
370+
<thead>
371+
<tr>
372+
<th colspan="2">Current Device Info</th>
373+
</tr>
374+
</thead>
375+
<tbody>
376+
<tr>
377+
<td>Board:</td>
378+
<td><a id="board" target="_blank"></a></td>
379+
</tr>
380+
<tr>
381+
<td>Version:</td>
382+
<td><span id="version"></span></td>
383+
</tr>
384+
<tr>
385+
<td>Build Date:</td>
386+
<td><span id="builddate"></span></td>
387+
</tr>
388+
<tr>
389+
<td>MCU Name:</td>
390+
<td><span id="mcuname"></span></td>
391+
</tr>
392+
<tr>
393+
<td>Board ID:</td>
394+
<td><span id="boardid"></span></td>
395+
</tr>
396+
<tr>
397+
<td>UID:</td>
398+
<td><span id="uid"></span></td>
399+
</tr>
400+
</tbody>
401+
</table>
402+
<div class="buttons centered">
403+
<button class="purple-button ok-button">Close</button>
404+
</div>
405+
</div>
336406

337407
<script type="module" src="/js/script.js"></script>
338408
</body>

js/common/ble-file-transfer.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import {FileTransferClient as BLEFileTransferClient} from '@adafruit/ble-file-transfer-js';
2+
3+
// Wrapper for BLEFileTransferClient to add additional functionality
4+
class FileTransferClient extends BLEFileTransferClient {
5+
constructor(bleDevice, bufferSize) {
6+
super(bleDevice, bufferSize);
7+
}
8+
9+
async versionInfo() {
10+
// Possibly open /boot_out.txt and read the version info
11+
let versionInfo = {};
12+
console.log("Reading version info");
13+
let bootout = await this.readFile('/boot_out.txt', false);
14+
console.log(bootout);
15+
if (!bootout) {
16+
console.error("Unable to read boot_out.txt");
17+
return null;
18+
}
19+
bootout += "\n";
20+
21+
// Add these items as they are found
22+
const searchItems = {
23+
version: /Adafruit CircuitPython (.*?) on/,
24+
build_date: /on ([0-9]{4}-[0-9]{2}-[0-9]{2});/,
25+
board_name: /; (.*?) with/,
26+
mcu_name: /with (.*?)\r?\n/,
27+
board_id: /Board ID:(.*?)\r?\n/,
28+
uid: /UID:([0-9A-F]{12,16})\r?\n/,
29+
}
30+
31+
for (const [key, regex] of Object.entries(searchItems)) {
32+
const match = bootout.match(regex);
33+
34+
if (match) {
35+
versionInfo[key] = match[1];
36+
}
37+
}
38+
39+
return versionInfo;
40+
}
41+
}
42+
43+
export {FileTransferClient};

js/common/dialogs.js

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,10 @@ class DiscoveryModal extends GenericModal {
329329
let ip = this._currentModal.querySelector("#ip");
330330
ip.href = `http://${deviceInfo.ip + port}/code/`;
331331
ip.textContent = deviceInfo.ip;
332+
this._currentModal.querySelector("#builddate").textContent = deviceInfo.build_date;
333+
this._currentModal.querySelector("#mcuname").textContent = deviceInfo.mcu_name;
334+
this._currentModal.querySelector("#boardid").textContent = deviceInfo.board_id;
335+
this._currentModal.querySelector("#uid").textContent = deviceInfo.uid;
332336
}
333337

334338
async _refreshDevices() {
@@ -378,11 +382,43 @@ class DiscoveryModal extends GenericModal {
378382
}
379383
}
380384

385+
class DeviceInfoModal extends GenericModal {
386+
async _getDeviceInfo() {
387+
const deviceInfo = await this._showBusy(this._fileHelper.versionInfo());
388+
this._currentModal.querySelector("#version").textContent = deviceInfo.version;
389+
const boardLink = this._currentModal.querySelector("#board");
390+
boardLink.href = `https://circuitpython.org/board/${deviceInfo.board_id}/`;
391+
boardLink.textContent = deviceInfo.board_name;
392+
this._currentModal.querySelector("#builddate").textContent = deviceInfo.build_date;
393+
this._currentModal.querySelector("#mcuname").textContent = deviceInfo.mcu_name;
394+
this._currentModal.querySelector("#boardid").textContent = deviceInfo.board_id;
395+
this._currentModal.querySelector("#uid").textContent = deviceInfo.uid;
396+
}
397+
398+
async open(workflow, documentState) {
399+
this._workflow = workflow;
400+
this._fileHelper = workflow.fileHelper;
401+
this._showBusy = workflow.showBusy.bind(workflow);
402+
this._docState = documentState;
403+
404+
let p = super.open();
405+
const okButton = this._currentModal.querySelector("button.ok-button");
406+
this._addDialogElement('okButton', okButton, 'click', this._closeModal);
407+
408+
const refreshIcon = this._currentModal.querySelector("i.refresh");
409+
this._addDialogElement('refreshIcon', refreshIcon, 'click', this._refreshDevices);
410+
411+
await this._getDeviceInfo();
412+
return p;
413+
}
414+
}
415+
381416
export {
382417
GenericModal,
383418
MessageModal,
384419
ButtonValueDialog,
385420
UnsavedDialog,
386421
DiscoveryModal,
387-
ProgressDialog
422+
ProgressDialog,
423+
DeviceInfoModal
388424
};

0 commit comments

Comments
 (0)