Coder Social home page Coder Social logo

Localstorage on the Pebble about pebblejs HOT 4 OPEN

pebble avatar pebble commented on July 23, 2024
Localstorage on the Pebble

from pebblejs.

Comments (4)

Meiguro avatar Meiguro commented on July 23, 2024

That's right, pebble.js doesn't currently use persistent storage.

The issue lies in how the pebble.js C shell would know what to do with the data. The C shell only knows enough to display what is shown currently. Since it forwards all events to the phone, it means it doesn't know what to display based on a given input even if it has the data locally.

If we wanted to solve that problem, the solution is a DSL or a vastly simplified and limited API that hooks events to combinations of actions and data, but this would mean using JavaScript as a vessel for a DSL or API vastly simpler than both JavaScript and C. A limiting DSL or API is often frustrating to use if designed poorly.

We can make the extreme case of using JavaScript as the DSL. I have thought about this idea, but there would still be issues with code dependency. For example, if your button handler called a function from a charting library, the resulting compiled code would be too great to send over bluetooth.

If the idea is to only instantly show what was last shown on the watch, then that greatly simplifies the problem. That is in fact something I've entertained and is possible. There are still some issues such as how pebble.js should decide which screen to snapshot. Perhaps the simplest implementation is to call a function that would snapshot the current screen.

It is possible to extend the snapshot idea by adding instrumentation over button handlers that call or hide windows to have a snapshot per window and naively display the last saved snapshot of the window. This might be the feature you're requesting. There are some issues with this however such as asynchronous callbacks that show/hide a window. pebble.js would need to somehow know the callback belonged to a certain window's button press, such as by a new API. This may still need a snapshotting function to prevent automatically snapshotting a window while it is displaying "Loading..."

If the idea is to save information on the watch so that switching phones means the data travels with the watch, that is also possible. There is one issue however; providing access to this means removing future persistent storage space pebble.js may use to cache data such as snapshotting the screen as outlined above. It may be in your interest to save the information in an online server indexed by the Pebble account token obtained via Pebble.getAccountToken().

from pebblejs.

samuelmr avatar samuelmr commented on July 23, 2024

PebbleJS can currently subscribe to acceleration service:
Accel.init() => simply_accel_set_data_create()

Would it be impossible to call persistent data storage functionality in a similar fashion:
Watch.persist(key, value) => persist_write_data(key, value)

The watch display doesn't have to be changed when the persist functions are called.

It would be great if also e.g. data logging API and wakeup API could be exposed to PebbleJS.

from pebblejs.

randomite avatar randomite commented on July 23, 2024

In addition it would awesome if there was some way to program logic on the watch in the event of the watch not being connected to the phone, such as reading data from persistent storage and writing it to the screen.

from pebblejs.

Meiguro avatar Meiguro commented on July 23, 2024
Would it be impossible to call persistent data storage functionality in a similar fashion:
Watch.persist(key, value) => persist_write_data(key, value)

It is possible, but it would reduce the amount of persistent storage pebble.js may use as a cache in the future since it is limited to 4K. I suppose however now is the best time to experiment. I could permit a smaller amount, such as 2K, for example.

It would be great if also e.g. data logging API ...

Unfortunately PebbleKit JS, the framework pebble.js is built on top of, doesn't support data logging. I can, however, create versions of pebble.js that use PebbleKit iOS/Android, though it would require the user to create a complementary phone app. Regardless, this is planned far in the future after pebble.js has a good featureset. It'll probably also make it very confusing to explain what pebble.js and the PebbleKits are at that point.

... wakeup API could be exposed to PebbleJS.

I definitely plan to do that! There is a ticket #7, though I forgot to reply.

In addition it would awesome if there was some way to program logic on the watch in the event of the watch not being connected to the phone, such as reading data from persistent storage and writing it to the screen.

I agree, it would be awesome. The difficulty however is the first half of my first reply before this one. But it's a good reminder that I should experiment while pebble.js is still in beta.

from pebblejs.

Related Issues (20)

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.