circuitpython / web-editor Goto Github PK
View Code? Open in Web Editor NEWOnline web editor for CircuitPython
Home Page: https://code.circuitpython.org
License: MIT License
Online web editor for CircuitPython
Home Page: https://code.circuitpython.org
License: MIT License
This has been super helpful with the WebSerial ESPTool repo and I can definitely see it being useful here.
It looks like this will end up being 2 steps:
(Was circuitpython issue 5861)
CircuitPython version
Adafruit CircuitPython 7.1.0 on 2021-12-28; Adafruit Feather Bluefruit Sense with nRF52840
Code/REPL
n/a
Behavior
When I try to "Request Bluetooth Device" from Chrome (code.circuitpython.org)
I pick the 'CIRC' device and click 'Pair', then I get a Bluetooth busy spinner that never goes away.
Description
Chrome 96.0.4664.110 (Official Build) (64-bit)
--enable-experimental-web-platform-features
--enable-features=WebBluetoothNewPermissionsBackend
Windows 10 Version 21H1
Additional information
Requesting any Bluetooth device...
script.js:520 > Requested CIRPY
script.js:374 connected BluetoothRemoteGATTServer {device: BluetoothDevice, connected: true}
script.js:382 (2) [BluetoothRemoteGATTService, BluetoothRemoteGATTService]
script.js:384 Getting Transfer Service...
ble-file-transfer.js:79 caught connection error DOMException: Authentication canceled. undefined
ble-file-transfer.js:100 caught write error TypeError: Cannot read properties of null (reading 'writeValueWithoutResponse')
at FileTransferClient._write (ble-file-transfer.js:87)
at FileTransferClient.listDir (ble-file-transfer.js:467)
at async showBusy (script.js:186)
at async fileExists (script.js:219)
at async loadEditor (script.js:488)
at async switchToDevice (script.js:392)
at async onRequestBluetoothDeviceButtonClick (script.js:522)
at async HTMLButtonElement. (script.js:598) TypeError: Cannot read properties of null (reading 'writeValueWithoutResponse')
at FileTransferClient._write (https://code.circuitpython.org/_snowpack/pkg/@adafruit/ble-file-transfer.js:87:38)
at FileTransferClient.listDir (https://code.circuitpython.org/_snowpack/pkg/@adafruit/ble-file-transfer.js:467:20)
at async showBusy (https://code.circuitpython.org/assets/js/script.js:186:18)
at async fileExists (https://code.circuitpython.org/assets/js/script.js:219:19)
at async loadEditor (https://code.circuitpython.org/assets/js/script.js:488:9)
at async switchToDevice (https://code.circuitpython.org/assets/js/script.js:392:5)
at async onRequestBluetoothDeviceButtonClick (https://code.circuitpython.org/assets/js/script.js:522:9)
at async HTMLButtonElement. (https://code.circuitpython.org/assets/js/script.js:598:9)
ble-file-transfer.js:100 caught write error TypeError: Cannot read properties of null (reading 'writeValueWithoutResponse')
at FileTransferClient._write (ble-file-transfer.js:87)
at FileTransferClient.listDir (ble-file-transfer.js:468)
at async showBusy (script.js:186)
at async fileExists (script.js:219)
at async loadEditor (script.js:488)
at async switchToDevice (script.js:392)
at async onRequestBluetoothDeviceButtonClick (script.js:522)
at async HTMLButtonElement. (script.js:598) TypeError: Cannot read properties of null (reading 'writeValueWithoutResponse')
at FileTransferClient._write (https://code.circuitpython.org/_snowpack/pkg/@adafruit/ble-file-transfer.js:87:38)
at FileTransferClient.listDir (https://code.circuitpython.org/_snowpack/pkg/@adafruit/ble-file-transfer.js:468:20)
at async showBusy (https://code.circuitpython.org/assets/js/script.js:186:18)
at async fileExists (https://code.circuitpython.org/assets/js/script.js:219:19)
at async loadEditor (https://code.circuitpython.org/assets/js/script.js:488:9)
at async switchToDevice (https://code.circuitpython.org/assets/js/script.js:392:5)
at async onRequestBluetoothDeviceButtonClick (https://code.circuitpython.org/assets/js/script.js:522:9)
at async HTMLButtonElement. (https://code.circuitpython.org/assets/js/script.js:598:9)
script.js:345 DOMException: Connection failed for unknown reason. undefined
script.js:525 Argh: disconnected
script.js:505 true
script.js:345 DOMException: Connection failed for unknown reason. undefined
script.js:505 true
script.js:345 DOMException: Connection failed for unknown reason. undefined
script.js:505 true
Add a hover effect on buttons by darkening 15%. This should be instant and match adafruit.com.
Is there a way to upload files to my CircuitPython device using this web editor? If so, it should be easier to find. If not, it should be added.
adafruit-circuitpython-microbit_v2-en_US-7.3.3.combined.hex; microbit_v2
code.circuitpython.org
Uncaught (in promise) TypeError: navigator.bluetooth.getDevices is not a function
Argh: NetworkError: Connection failed for unknown reason.
No response
None
BLE, USB, WEB
Google Chrome 114.0.5735.133
No response
No response
No response
Currently this isn't working very smoothly.
Adafruit CircuitPython 8.1.0 on 2023-05-22; ESP32-S3-Box-Lite with ESP32S3
WEB
Google Chrome 113.0.5672.127
No response
1, Install Ngrok/oray or any NAT app on the router.
2, Forward Circuitpython device port 80
to the public internet port 8333
.
3, Access NAT domin (ex: 84c5df439d74.ngrok-free.dev:8333
) from the public internet.
4, After I see the Welcome page, click the full code editor
.
In the code editor, it shows my devices can not be connected. But both welcome page and file browser work fine. I guess maybe the reason is repl
in full code editor
use another port to connect? Most of free NAT support only 1 port access.
No response
https://learn.adafruit.com/wirelessly-code-your-bluetooth-device-with-circuitpython/device-setup and https://code.circuitpython.org/ recommends users to enable two experimental flags in Chrome.
The enable-experimental-web-platform-features
is a flag that affects all websites in Chrome. It should not be enabled unless user knows their browsing experience in Chrome will be impacted.
The enable-web-bluetooth-new-permissions-backend
flag on the other hand only affects Bluetooth pickers in Chrome. That said, this may break other websites that use Web Bluetooth as well.
Are those flags really required?
If not, please remove them from those pages.
For additional help beyond what can be fit into a help file, it makes sense to link to Adafruit Learn System guides for the moment. At this time there isn't a specific list of places to add links, so this is rather open ended.
CircuitPython 8.2.0
WEB
Chrome
No Errors
import time
while True:
print("Hello World!")
time.sleep(1)
No response
No response
Adafruit CircuitPython 8.1.0 on 2023-05-22; ESP32-S3-Box-Lite with ESP32S3
USB, WEB
Google Chrome 113.0.5672.127
No response
It occurs occasionally and I am not sure how to reproduce it. I have uploaded a video for this, you can see that the terminal is still working but the page freeze.
When the page is loading, the loading animation prevents you from doing anything in your code. So if the device connection fails for any reason, the page will just freeze on the loading animation notification. There is even no chance to copy and paste your code, so everything unsaved will be lost. This can be improved and is necessary, I think.
No response
No response
8.1.0 - beta 2
WEB
Chrome not-latest 112.0.5615.138 (Official Build) (win11 64-bit)
(it's now updating)
Goto your board over wifi having ejected/unmounted the usb drive if connected to a device instead of power supply.
Move cursor to end of line in a file like settings.toml.
Use copy and paste keyboard shortcuts with nothing selected.
Cursor moves to new duplicated line.
Use keyboard modifier and arrow keys to select a part of the new line.
Observe the line above get highlighted instead
You can see in the screenshot that the second line (line5) has the cursor, and I've used the keyboard to select my AIO key, but the line above has been highlighted instead.
Adafruit CircuitPython 8.1.0 on 2023-05-22; ESP32-S3-Box-Lite with ESP32S3
WEB
Google Chrome 113.0.5672.127
No response
If the code is longer than 1 single page, the Serial and Editor button will dissappear. So I have to reopen something short in order to open the serial monitor.
No response
No response
Since this is starting to grow in popularity, it might be good to add some templates. Something like https://github.com/adafruit/Raspberry-Pi-Installer-Scripts/tree/main/.github/ISSUE_TEMPLATE might be a good starting point.
Use the directory picker to get access to a CIRCUITPY drive: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/webkitdirectory
It looks like there is a function to define all dot files as text. I assume to accommodate the previous .env web workflow configuration.
web-editor/assets/js/common/file_dialog.js
Lines 64 to 66 in c361885
Since .env files have been replaced with settings.toml, should the web editor have toml added to extensionMap and dot files removed?
N/A
USB
N/A
N/A
Updating to circuitpython-repl-js 1.2.1 breaks the USB workflow
The USB Workflow needs to be updated to not break with the latest circuitpython-repl-js, which was updated for reliability and so it works with the CircuitPython Installer.
No response
This will make it easier to switch between connections.
This is for the Title Bar. Currently it won't parse it as anything other than raw serial output.
it will be much easier to launch, and switch between editors and web docs tabs.
Transfer to code.circuitpython.org if on http. Similar to #23.
I noticed that even though the BLE File Transfer library was updated and then a new Pull Request was merged, code.circuitpython.org still has the old BLE File Transfer library code. This may be as simple as updating the package version of BLE File Transfer.
The web workflow doesn't take into account the board's port, and always tries to connect to 80.
When the board is configured uses a different port, it can't connect back to it. (CIRCUITPY_WEB_API_PORT
)
Unable to connect. The device 192.168.1.92 was not found. Be sure it is plugged in and set up properly.
(from adafruit/circuitpython#7168 )
Ensure we are transferred to code.circuitpython.org if on http.
This should match circuitpython.org.
I did not see a bug template or anything sorry, so I will try to give all the info I have here.
When trying to use the web editor I am running into the following error:
I don't see self
being referenced anywhere else in the codebase, should it be a this
?
Adafruit CircuitPython 8.0.0 on 2023-02-06; Raspberry Pi Pico W with rp2040
Board ID:raspberry_pi_pico_w
UID:E66141040356482F
MAC:28:CD:C1:04:37:4B
Clicking reconnect, then request device works for some reason, but it should just be one click.
Test condition:
Procedure:
Disconnect
button on the top-right cornerTried:
This issue will mostly serve as a thread that other can contribute to with some ideas for future functionality with the CircuitPython Code Editor. Here's an initial list I came up with based on taking a look at https://python.microbit.org/v/beta:
Feel free to contribute your own ideas.
Adafruit CircuitPython 8.1.0-beta.2, ESP32-S3-DevKitC-1-N8R2 board.
WEB
Firefox and Chrome, Linux, Android and MAC.
No response
http://cpy-2b4f34.local/code/ don't load the code editor. Some weeks ago it was working perfectly for me.
When the code page opens, I quickly see the following string: "Unable to connect. The device [local IP address] was not found. Be sure it is plugged in and set up properly."
Then I see this:
I erased and flashed a few times the CircuitPython binary.
I tested to change the CIRCUITPY_WEB_API_PORT.
I tested in two different ESP32-S3 as also in one ESP32-S2, that always worked well for me.
I also tested on a different wifi network, with only my PC and the ESP32-S3 board.
Tested on 2 different Linux Ubuntu computers, on one Android Phone and on one MAC.
When is is possible, plz.
For USB and possibly BLE, we require the user to perform at least 2 steps to connect. If the user cancels in the middle of this, I'm not sure if this is being handled properly. Additionally, the UI could use some improvement to better inform the user that a step is complete.
I don't think this affects Web Workflow because it's basically 1 step, though I suppose if the user fails to type in credentials it may not be handled properly, so that should probably be checked too, though I imagine the result is they'll either get an error or it will prompt them again next time.
Here's what I think needs to be fixed for this issue to be complete:
I get an about:blank#blocked page from CLICKING the "about://flags/#enable-web-bluetooth-new-permissions-backend" link in the code.circuitpython.org page
#17 is a pr that changes the link to chrome://flags/#enable-web-bluetooth-new-permissions-backend
[CLICKING added for clarity}
On MacOS, with a RP2040 Zero board.
print("Hello")
The following message output repeats in the console:
write
usb-file-transfer.js:150 Setting modification time not currently supported in USB Workflow.
writeFile @ usb-file-transfer.js:150
await in writeFile (asynchrone)
writeFile @ file.js:67
writeFile @ workflow.js:285
up @ script.js:393
saveFile @ workflow.js:232
saveFileAs @ workflow.js:249
await in saveFileAs (asynchrone)
(anonyme) @ script.js:77
script.js:400 write failed ReferenceError: encoder is not defined
at oa.writeFile (usb-file-transfer.js:156:13)
at async Nl.writeFile (file.js:67:13)
at async aa.showBusy (workflow.js:149:22)
at async aa.writeFile (workflow.js:284:16)
at async aa.up [as _saveFileContents] (script.js:393:13)
at async aa.saveFile (workflow.js:232:13)
at async aa.saveFileAs (workflow.js:249:17)
at async HTMLButtonElement.<anonymous> (script.js:77:20) ReferenceError: encoder is not defined
at oa.writeFile (https://code.circuitpython.org/assets/js/script.js:13:46341)
at async Nl.writeFile (https://code.circuitpython.org/assets/js/script.js:13:3175)
at async aa.showBusy (https://code.circuitpython.org/assets/js/script.js:13:30340)
at async aa.writeFile (https://code.circuitpython.org/assets/js/script.js:13:32214)
at async aa.up [as _saveFileContents] (https://code.circuitpython.org/assets/js/script.js:16:769)
at async aa.saveFile (https://code.circuitpython.org/assets/js/script.js:13:31429)
at async aa.saveFileAs (https://code.circuitpython.org/assets/js/script.js:13:31685)
at async HTMLButtonElement.<anonymous> (https://code.circuitpython.org/assets/js/script.js:15:1877)
script.js:79 Current File Changed to: null
Currently it goes to the next browser item
This may or may not be an issue. I need to test when all Web Workflow devices are on ports other than 80 to see if it works.
With 1 device set up with port 8080:
With 2 or more devices set up with port 8080:
With 1 device set up with port 8080 and 1 device set up with port 80:
Just test if it works properly on a Raspberry Pi 400 desktop running the latest updates. I don't believe it comes with chrome, so maybe follow this first: https://pimylifeup.com/raspberry-pi-chromium-browser/
hi I tried to post this to forum topic about microbit V2, but when submitting some f... crazy thing stopped me becasue of "CMSIS-DAP" word but then it was also impossible to submit after edits, I am starting to hate entire microbit thing deeply....
I tried microbit V2 (CP 7.1.0 beta 1 and nightly build too) on windows and also on mac but its frustrating - on mac I was able to go to editor once but then it hanged after first save&run too (actually then impossible to shutdown mac because of chrome, I must force switch it off).
On windows in chrome I tested chrome://bluetooth-internals, where lots of "Unknown or Unsupported Devices with different MAC started to occur - this also happened once from webeditor in "pairing dialog" - stream of unsupported devices after powering up microbit. Also on windows I see immediately after power-up in connected devices (so without any pairing activation with reset during fast yellow leds) device "BBC microbit CMSIS-DAP." and when I try to add, CIRPY shows as possible. (Here I mostly don't paired and removed also the CMSIS-DAP thing before trying webeditor connecting)
On Mac, I am now trying also chrome://bluetooth-internals and here is CIRCUITPY531b device but trying to inspect it from here to show services, means rotating circle only (and just after inspect, it was red message unsupported device also - the same trying to connect). On CIRPY device services are inspectable here. Now after trying to Pair CIRPY from webeditor, I see again only blue animated gif and latest chrome asi again totally hung.
irrelevant
BLE, USB, WEB
Version 111.0.5563.146 (Official Build) (x86_64)
No response
Click and drag to select a single word or multiple words in a single line.
Notice that the background color of the selected words does not change.
Once the selection spans multiple lines, a bright orange selection background appears.
No response
If you just type code.circuitpython.org into the browser, then the USB connection will not work. You must be on a secure site (https://code.circuitpython.org/) for the JavaScript to work correctly.
The website should automatically redirect to HTTPS if it goes to the HTTP site.
Possibly add a "Forget all known Bluetooth Devices" feature. While this is possible through the browser menus, it's difficult to find and requires a lot of navigating. This can make it easier to clear out old devices for troubleshooting the connection.
Ctrl/Cmd + S should save
Ctrl/Cmd + O should open
Maybe + R to run and something else for switching between views
etc...
See #34 for more details.
Essentially runCode()
was copied and pasted over to workflow.js from script.js, but a call to changeMode()
was not adjusted and was out of scope.
Make current path in file dialog more obvious what it is. When you first go there, it only shows a / and isn't very noticeable until you navigate. Possibly prepend board name to it.
The same thing should also be done with the path above the editor.
At the same time, these changes should be responsive so they work on mobile devices.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.