-
-
Hi,
I'm using
espruino -d Bangle.js -w index.js
to connect to my Bangle.js in watch mode. Everytime I change the file in my local IDE, it is re-uploaded and re-executed like expected.I've noticed that sometimes after I changed the file and it gets uploaded, the console shows
____ _ | __|___ ___ ___ _ _|_|___ ___ | __|_ -| . | _| | | | | . | |____|___| _|_| |___|_|_|_|___| |_| espruino.com 2v17 (c) 2021 G.Williams > >Upload Complete
while sometimes only
>Upload Complete
is shown, especially when I'm working on a larger file.
In the latter case, however, the state on the watch is not reset correctly and event handlers are added up. For example, this code
Bangle.on('touch', function (zone, e) { console.log(e); }); console.log("Ready");
makes the log message appear multiple times after multiple file uploads.
When I long-press the button and then trigger a re-upload, the state is reset correctly.
Is there anything I can do to re-initialize the event handlers before each re-upload in watch mode?
Unfortunately, the small code example above does not reproduce the problem. It only happens with some larger code file.
Kind regards,
Johannes -
-
Firmware: https://www.espruino.com/Download
Update instructions: https://www.espruino.com/Bangle.js2#firmware-updates
Now that the linked video is still from Bangle 1, but the description is correct.
-
I have to press the button to activate the backlight. Is this the intended behaviour?
No - actually it was already fixed in a firmware update :) If you update to a 'cutting edge' build, or 2v11 when it's released, the backlight will turn on for watch twists as well.
I updated to the cutting edge, and not it works! Thanks!
-
My Bangle 2 has arrived, yeah! Thanks so much, Gordon, for all the effort you put into this great project!
I have a question regarding the LCD backlight: No matter which wake up method I choose (Face up, Touch or Twist), when I execute this action, the display does not light up. I have to press the button to activate the backlight. Is this the intended behaviour? Note that the little lock disappears, so I guess, the action is detected correctly.
I'd highly appreciate an option for also enabling the backlight during wake up, since there are lots of situations where the passive lighting isn't enough to read the display.
Kind regards,
Johannes -
I also find it annoying, particularly, when you start an app that also displays "loading..." behind it (as, e.g., the Anton Clock, or almost any other app that is installed per default on the device).
I'd appreciate if it was configurable in the settings. It was probably introduced to give the user feedback that something is about to happen, but the only long delay I have noticed, is after pressing the button to enter the menu (Bangle 2). Here, a short vibration as feedback would be sufficient. -
@JumJum
code.replace(selected, ...
is dangerous since it may also override other places that, by accident, contain the same code as the selection. There are better ways by using start and end of the selection and replacing only this part - but, again, let us leave this to another PR (that we'd be happy to receive from you!).Edit: Have a look at https://codemirror.net/doc/manual.html#api and try using
Espruino.Core.EditorJavaScript.getCodeMirror().replaceSelection(...)
. This should do the trick. -
https://prettier.io/docs/en/ignore.html#javascript
You can ignore certain lines/parts of the code with this special comment.
Implemeting "format only the selected code" is possible by using the Editor properties. This could be the next feature in another PR.
-
function formatCode() { var code = Espruino.Core.EditorJavaScript.getCode(); var cursor = Espruino.Core.EditorJavaScript.getCodeMirror().getCursor(); code = prettier.format(code, { parser: "babel", plugins: prettierPlugins, tabWidth: parseInt(Espruino.Config.TAB_SIZE), useTabs: Espruino.Config.INDENTATION_TYPE == "tabs", semi: true, singleQuote: true }); Espruino.Core.EditorJavaScript.setCode(code); Espruino.Core.EditorJavaScript.getCodeMirror().setCursor(cursor); }
get/setCursor principally seems to do the trick, however, it changes the scrolling position. The line with the cursor becomes the last line in the editor window. You can try this by e.g. using large app code like https://github.com/espruino/BangleApps/blob/master/apps/trex/trex.js
Any ideas how to fix this? -
@JumJum Sorry for the delay and thanks very much for your code. This is exactly the kind of starting point I needed.
Prettier doesn't need an internet connection, either. Here is what I did based on your initial example using prettier: https://github.com/neshanjo/EspruinoWebIDE/tree/code-formatting-prettier
Anybody here interested in this, can just checkout my fork and runnpm install
followed bynpm start
.My code also respects the indentation settings (tab width and tabs versus spaces).
Indeed, there is still some work to do:
- Save the current cursor position
- Hide the icon in Blockly mode
- Add a keyboard shortcut
- Maybe another icon.
I don't think, we need a settings page, though. I even think we should not have one in order to follow one code style. That's the idea behind prettier.
I also made another branch using js-beautify: https://github.com/neshanjo/EspruinoWebIDE/tree/code-formatting-js-beautify
IMO, the main (only?) advantage of js-beautify over prettier is the smaller size. Prettier is more or less THE standard in modern JS development and available in many code editors and even from the command line. This is a nice feature, especially for BangleJS where every app uses its own code formatting style. Furthermore, it is actively developed by a large team, while js-beautify claims on their Github page that they are in need of more contributors.
Just my 2ct. I'd be very happy to have any kind of code formatting soon.
My next steps are to work on point 1 (see list above) and submit a MR. 2+3 should be done very easily by someone more familiar with the project.
- Save the current cursor position
-
Thanks. I've seen the the Github repo for EspruinoWebIDE. Anyway, it will take some time to understand how everything works... Maybe already some simple questions: Should this be implemented as a plugin? How can the formatter be registered to a certain key combination?
And, regarding the beautifier link, why not use prettier?
https://prettier.io/
https://prettier.io/docs/en/browser.htmlIt is also open source and supported in almost any IDE - so it would provide consistent results also between different tools...
-
Hi together, I'd like to bring attention to this topic again. I think it would be really great to have a code formatter available. Not only does it unify our code base e.g. in BangleApps, it can also prevent bugs (for instance, the typical if without braces problems, see https://softwareengineering.stackexchange.com/a/16530). I'm also willing to help implementing this (however, I'm not familiar with the code of EspruineWebIDE yet, so I'd need some help where to get started).
-
-
Hi there,
I have some questions regarding bluetooth settings:
- What does "Make Connectable" do and how is it different from the setting in the BLE submenu?
- I guess BLE on/off in the BLE menu is the overall Bluetooth on/off switch. What does "Programmable" mean?
- BLE on and Programmable off seems to work with GadgetBridge. But, when GB loses connection, can other people still connect and read data?
- Which are the recommended settings that nobody else can access my watch, but I can still use GadgetBrigde? I tried Whilelist -> Add device, but it always shows "Connect device to add to whitelist", even though I'm connected via GB or via Web Bluetooth.
Kind regards,
neshanjo - What does "Make Connectable" do and how is it different from the setting in the BLE submenu?
Aaargh! 🤦 Thanks!