Code Monkey home page Code Monkey logo

bangleapps's Introduction

Espruino JavaScript for Microcontrollers

 _____                 _
|   __|___ ___ ___ _ _|_|___ ___
|   __|_ -| . |  _| | | |   | . |
|_____|___|  _|_| |___|_|_|_|___|
          |_|

https://www.espruino.com           Join the chat at https://gitter.im/espruino/Espruino

About

Espruino is a JavaScript interpreter for microcontrollers. It is designed for devices with as little as 128kB Flash and 8kB RAM.

Please support Espruino by ordering one of our official boards or donating.

Documentation

If you have an Espruino board, please read the Quick Start Guide first.

Browse the Espruino Website (try using search in the top right), and read the FAQ.

There's also a Reference for JavaScript commands as well as Tutorials. However the documentation on the Espruino website will match the version available for download but not the latest version on GitHub.

Builds for the Espruino Board and Pico Board (built automatically for each Git commit) are available from here.

Other documentation of use is:

Support / Bugs

First, please try and check that your problem hasn't already been found or covered on our forum.

Submit bugs with clear steps to reproduce them: a small test case (not your whole program), and an actual and expected result. If you can't come up with these, please post on the forum first as it may just be something in your code that we can help out with.

Work on Espruino is supported by sales of our boards.

If your board isn't made by us but came pre-installed with Espruino then you should contact the manufacturers.

We try and support users of the boards we sell, but if you bought a non-official board your issue may not get addressed. In this case, please consider donating to help cover the time it takes to fix problems (even so, we can't guarantee to fix every problem).

License

Please see the LICENSE file.

Building

Check out the page on building Espruino.

Testing

There are a bunch of tests in the tests directory. See tests/README.md for examples on how to run them.

Current State

The officially supported boards are the best supported. They come pre-installed with Espruino and you are able to easily download and flash the latest versions of Espruino to them.

While Espruino can run on other boards, we make no money from them and so cannot afford to test, fix or support the firmware on them. We're dependent on the community.

You can download binaries from https://www.espruino.com/Download.

If you are a board manufacturer interested in getting your board officially supported, please check out this page.

For a list of supported boards, please see the boards folder.

Main supported platforms are:

  • STM32 (F1, F3, F4, L4)
  • nRF52
  • nRF51
  • ESP8266
  • ESP32
  • Linux

Espruino has been ported to other boards and platforms (such as EFM32 and SAMD), but these have a habit of being contributed and then never maintained. All boards that this has happened to reside in the UNMAINTAINED_BOARDS branch.

Modification

Check out the documentation on the build process first - this should clear up a lot of potential questions about the Espruino architecture.

Please see CONTRIBUTING.md for some hints about code style/etc.

You can auto-build documentation for all source files - see doxygen/README.md

Any more questions? ask on the forum.

Porting to new devices

If you're using an existing architecture everything can be done from boards/BOARDNAME.py. See a similar board's .py file as an example.

However for a new architecture there are a bunch of different files to modify.

  • boards/*.py files describe the CPU, available pins, and connections - so the relevant linker script, headers + docs can be created
  • boards/pins/*.csv are copies of the 'pin definitions' table in the chip's datasheet. They are read in for STM32 chips by the boards/*.py files, but they are not required - see boards/MICROBIT.py for an example.
  • Global build options are handled in Makefile
  • The make directory contains arch-specific Makefile fragments
  • Extra libraries like USB/LCD/filesystem are in Makefile
  • Processor-specific code in targets/ARCH - eg. targets/stm32, targets/linux
  • Processor-specific libs (like the SDK) in targetlibs/ARCH
  • src/jshardware.h is effectively a simple abstraction layer for SPI/I2C/etc, which should be implemented in targets/ARCH/jshardware.c

Adding libraries

  • Create jswrap_mylib.c/h in libs/
  • Create library functions (see examples in other jswrap files, also the comments in scripts/common.py)

See libs/README.md for a short tutorial on how to add your own libraries.

Using Espruino in your Projects

If you're using Espruino for your own personal projects - go ahead, we hope you have fun - and please let us know what you do with it on https://www.espruino.com/Forum!

If you're planning on selling the Espruino software on your own board, please:

  • Let us know, we might be able to help.
  • Read the terms of the MPLv2 Licence that Espruino is distributed under, and make sure you comply with it
  • MPLv2 dictates that any files that you modify must be made available in source form. New files that you create don't need to be made available (although we'd encourage it!)
  • You won't be able to call your board an 'Espruino' board unless it's agreed with us (we own the trademark)
  • You must explain clearly in your documentation that your device uses Espruino internally
  • Please don't fork Espruino - improvements get very hard to share, and in the long run everyone loses.
  • Please give something back to the project - be it code improvements, documentation or support.

We spend a lot of time supporting Espruino on the forums, but can only do so because we make money from the sales of Espruino boards. If your users request support from us then we have absolutely no obligation to help them. However, we'll be a lot more motivated if you're actively helping to improve Espruino for all its users (not just your own).

bangleapps's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bangleapps's Issues

Progress bar for uploads

Doing properly would need changes to the Puck.js/UART lib, but we could just split up write commands for each file and use that to do a progress bar.

Settings not applying for most apps

Currently settings creates a widget so it's now only loaded if widgets are (eg for clocks) - but let's move the code into the 'boot' app so they run in boot0 all the time

"About" app

Display the Bangle.js pixel chooser, info about the watch and firmware versions, and maybe some credits

"Welcome" app

To display when Bangle.js first starts - explain what buttons do what, and how to add apps.

Minification

Currently apps are unminified and no modules are loaded. We could use EspruinoTools to do the work for us?

Bluetooth connection state messes up apps

The console was moved permanently onto Bluetooth, but I moved it back to 'auto' (so it goes to the screen if BT is disconnected) recently as it seemed good for debugging (so any errors get shown to the user).

But this means that BT connection state scrolls the screen and messes stuff up.

So we could:

  • Add a 'debug' option that, when false (default) moves the console to Bluetooth. When true you get the scrolling, but as you're developing you put up with it :)
  • Add an option to Espruino to disable the Connection State messages
  • Change apps/widgets to clear their backgrounds all the time, so scrolling was less of a big deal
  • Leave the console on Bluetooth permanently - but then you don't see app erros

speedo - miles instead of km ?

I opened speedo in my car and saw 66 while I was almost going with ~110km/h.

I took a look and couldn't find something related in the code except that there is no "special" calculations in speedo.js but I can quickly multiply with 1.60934 (is 1km) If that's the case.

Gesture collector website

http://forum.espruino.com/comments/15082797/

We wanted to do this for Nodeconf and never got around to it.

A website where you connect via Web Bluetooth and then perform a bunch of gestures. They all get saved online and then you can use that information to train a tensorflow model - either for you or based on everyone's data.

Filters/Search

There's some HTML in there to display tabs for filtering - we should display markers on each item based on 'tags' JSON and then allow filtering by those

Some issues with the GPS Recorder App

1.

The GPS Recorder App (its corresponding widget) modifies the color of the Watch Face.
Should the Watch Face App be corrected or should it be the GPS Recorder App?
IMG_3369

2.

Despite the Watch Face showing the proper time, the date and time of the recorded track are wrong.
Image

3.

The last character of the .gpsrc0 files is not displayed correctly in the App Loader (Windows 10).
Image  2

4.

There are some minor tabulation issues in the .kml file.
Image

[Suggestion] Apps versioning

I think it will help to have some versioning of the apps, maybe just date/timestamp would be enough. Just something that I'd know, if something changed and that I should upload new version of the app.
And with versions, also changelog would be helpful.

How to ease development/preview in emulator

The bootloader currently defines 'drawWidgets' and this means that if you just do a direct upload to the watch (or run something in the emulator) it's not there and causes an error. There may be more things in the future where this is an issue.

Maybe Bangle.js should just define those variables internally at boot time? That does obviously make stuff a bit less flexible though

Installed settings from app cause Syntax error

Hi,

does https://banglejs.com/apps/ has the latest version?

Uncaught SyntaxError: Expecting a valid value, got ID
at line 1 col 110
...false,"clock":null,"12hour":galse,"distance":"kilometer"}
^

require('Storage').list()
=[
".boot0",
".bootcde",
"+boot",
"+launch",
"-launch",
"+miclock",
"-miclock",
"*miclock",
"+setting",
"-setting",
"@setting",
"*setting"
]
require('Storage').read("@setting")
="{"ble":true,"dev"" ... "nce":"kilometer"}"
console.log(require('Storage').read("@setting"))
{"ble":true,"dev":true,"timeout":10,"vibrate":true,"beep":true,"timezone":0,"HID":false,"clock":null,"12hour":galse,"distance":"kilometer"}
=undefined

Resizable widgets

Currently widgets set their size when they are loaded - but maybe it'd make sense to have it dynamic. Draw calls could return a width and drawWidgets could assign an X coordinate as it iterated along.

Might make sense for:

  • Battery indicator - could expand to show 'charging' indicator
  • GPS recording - could hide itself when not enabled/recording

Thoughts? It'd make sense to do this now before the final release.

Removing widgets/existing apps when loading a new app

Following on from... aca3ce8#commitcomment-36387513

I'm not happy about the current solution (of manually removing listeners from objects) at all - so yes, having a destructor would help, but there'd have to be one for the clock app too. I'm considering maybe just modifying the Bangle.js firmware to allow load(appname) which would tear down everything and start afresh with the supplied JS file from Storage?

That obviously means you then can't have widgets that stay running - but they'd get removed anyway every time you long-press BTN3.

What I could do is add a E.on('kill' event which gets fired just before everything is torn down, so widgets/apps could save their state. It might be a useful thing for Espruino in general.

Special Chars for "id": "aclock"

just stumbled over special chars in the app name aclock.

require('Storage').list()
=[
".bootcde",
"+aclo\xEB\xEF%", <---- guess some hidden chars in app.json
"-aclock",
"*aclock",
"+sbat", ...
"+setting",
"-setting",
"=setting",
"@setting",
"*setting"
]

Bluetooth: off

Don't do MRF.sleep if bluetooth is set to off in settings and we're currently connected - it stops the app loader from uploading apps

App version compatibility

Should apps report which firmware version they need?

While we're still on 2v04.xyz firmwares I don't think this is sensible (especially as travis mis-numbers them) but when we move to version numbers I think it's fair to say requires 2v05/etc and check this against the current firmware.

reported in http://forum.espruino.com/comments/15092142/

Get time from GPS on boot

Bangle.js's RTC is only 24 bit, which means an offset is stored in RAM and gets lost on reboot.

To work around this we could attempt to grab the time from the GPS module (if it's got a time in it)

GPSTime broken

Firmware download from site today along with latest code from BangleApps.

Similar issue with apps/firmware last Wednesday too. But I was also getting GPS time errors on main settings screen last week. And only satellite image showing on screen in app last week, not satellite count.

gpstime

Reset via BTN3 causes error messages

Looks like bootloader loads the clock app before loading widgets.

Output:

Uncaught ReferenceError: "widget" is not defined
at line 1 col 30
eval(require("Storage").read(widget))
^
in function called from line 127 col 103
...re("Storage").read(widget)));
`

Switching to menu and back does not cause errors and widgets are loaded properly.

Any hints how to fix it?

Is this the expected load order?

  • setting
  • widgets
  • clock if available

12/24 hour setting

As mentioned at #70

Should we add a global setting for the time format used in clock faces, and ask that all clock faces read the setting and change accordingly?

Or does it just make sense to have a different clock app for each time format?

Pedometer widget causing battery drain

Looks like the pedometer widget is causing a bit of battery drain. It managed to drain my BangleJS completely in about 12 hrs.
I noted a separate thing, the screen came on a LOT more easily when the pedometer widget was installed. I initially thought it was due to me resetting the watch and getting new versions of the apps. But after I uninstalled the pedometer widget the 'screen on' behaviour went back to it's old self.

I just noted this line of code and am wondering does this kick the screen back to on ?
https://github.com/espruino/BangleApps/blob/master/apps/wpedom/pedometer_widget.js#L44

In that case, maybe we should handle the lcdPower event and only call draw when the screen is turned on ?

P.S. I am going to start handling the step event in my app and report back if I notice similar drain. I only draw on screen when LCD power is on.

P.S.2 Firmware details

{
  VERSION: "2v04.294",
  GIT_COMMIT: "d0cfc724",
  BOARD: "BANGLEJS",
  FLASH: 524288, RAM: 65536,
  SERIAL: "a0cf0da6-xxxxxxxx",
  CONSOLE: "Bluetooth",
  MODULES: "Flash,Storage,hea" ... "ow,graphical_menu",
  EXPTR: 536883676 
}

"Try in emulator" throws

Hi together,

I've pre-ordered a few days ago and wanted to tinker around in the webIDE.
However, apparently var file = app.storage.find(f=>f.name[0]=='-'); returns nothing,
thus applications can not get loaded into the webIDE any longer and index.js:307 No entrypoint found for mclockis logged out.

Screenshot 2020-02-29 at 14 06 24

Cheers,

23Ro

Can't connect to Bangle.js when feature HID is set to ON

On my watch I have noticed that if I set HID to ON under settings, I am unable to connect to the watch (after a reboot) using Web Bluetooth: I get the Connection Failed error message in the Web IDE (whereas I can connect to it in all other situations).

12 hour clock calculations are wrong

Personally I don't care about 12 hour clock as I think it's an abomination and leads to people saying things like 12 am and 12 pm (neither of which exist) but this current code is wrong in a different way.

A time of 1205 (5 past noon) will get rendered as 12:05 AM and a time of 0005 (5 past midnight) will get rendered as 12:05 PM which I don't think even 12 hour clock lovers would think is correct.

Timezone from app Settings is not set after BTN3

Loaded app Settings and set "Time Zone " = 1
So now the app "Simple Clock" shows GMT+0001
Pressing BTN3 after loading another app, timezone is back to GMT+0000

Is there some startup code missing that loads settings?

Set Bangle.js Time issue

Observations:

  • When setting Bangle.js time using the Bangle.js loader the time displays correctly at first.
  • However, if pressing for a long time on BTN3 the time gets displayed with a time zone of 0.
  • To correct this, the user has to enter the correct time zone in settings, as it is 0 by default, even after setting the time using the Bangle.js loader.
  • Then, if accessing the clock by pressing on its app from the application menu, the correct time taking into account the set timezone gets displayed.
  • However if accessing the time by pressing for a long time on BTN3, the time gets displayed with a time zone of 0 at fist, and one has to wait till it gets updated (the next second, or next minute depending on the clock) to see the correct time taking into account the set time zone.

Don't enter menu if we've just powered on

We changed to starting the menu on button release (not press) - but that means that now the press of the button turns the LCD on, and the release opens the menu.

Previously it worked so that when in clock you could press any button to wake Bangle.js up (including the middle one) but it wouldn't go direct to settings. Now it's broken and you usually end up entering settings pretty often by accident

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.