Skip to content

ELUTE/nightscout-graph-pebble

 
 

Repository files navigation

A Pebble watchface for viewing Nightscout CGM data in graph format, like this:

Screenshot

To install, enable Developer Mode in the Pebble app on your phone, then open this pbw file in the Pebble app.

Urchin CGM is an Unopinionated, Ridiculously Configurable Human Interface to Nightscout. It's not released yet / in beta / a work-in-progress.

Circle CI

Setup

Set your Nightscout host and display units on the phone. You can customize the graph:

Status bar content

The status bar can display content from a variety of sources:

  • Uploader battery level - if your Nightscout data comes from a wired rig/xDrip. (e.g. 36%)
  • Raw Dexcom readings - raw sensor readings plus noise level. (e.g. Cln 97 104 106)
  • Uploader battery, Dexcom raw - combination of the above two. (e.g. 36% Cln 97 104 106)
  • Active basal - NS Care Portal - the currently-active basal rate based on treatments in Nightscout Care Portal. If a temp basal is currently active, shows the difference from normal basal and how many minutes ago the temp basal began. (e.g. 1.5u/h +0.6 (19))
  • IOB - NS Care Portal - IOB calculated based on treatments in Nightscout Care Portal. (e.g. 2.3 u)
  • Pump IOB - MiniMed Connect - the bolus IOB reported by a MiniMed Connect. (e.g. 2.3 u)
  • IOB and temp - OpenAPS - IOB and currently-active temp basal rate from the most recent OpenAPS status upload, or time since last successful status if the most recent upload indicates the loop failed to run. (e.g. (2) 1.1u 1.9x13 or (4) waiting | 23m)
  • Custom URL - text - if you want to summarize your data in a custom way.
  • Custom URL - JSON - show custom text, with support for a timestamp field to display recency (e.g. (3) your text).
  • Custom text - remind yourself whose glucose readings you're looking at, or leave a terse inspirational message.

How can I tell how recent the data is?

You can tell by the graph whether the data is recent. If there is no data missing, then the data is up to date. If the data is not recent, there will be a gap:

How can I tell why the data is not recent?

The data that you see on your watch travels like this: Rig -> Nightscout -> Phone -> Pebble.

There is a problem with the Phone -> Pebble connection; the last time the Pebble heard from the phone was 17 minutes ago. Maybe your phone is out of range. Maybe it's on airplane mode. Maybe you need to charge your phone.

There is a problem with the Nightscout -> Phone connection; the last time your phone successfully reached Nightscout was 11 minutes ago. Maybe your phone has bad reception. Maybe your Nightscout server is down.

There is a problem with the Rig -> Nightscout connection; the most recent data point in your Nightscout server is from 26 minutes ago. Maybe there's a problem with your receiver or uploader. Maybe the sensor fell out.

Layout

The configuration page includes a handful of layout options, such as:

For the adventurous, any layout can be customized: reorder the elements, change their heights, set a different background color...

Pump data

If you are using Nightscout to track data from an insulin pump, you may choose to display bolus history (as ticks) and/or basal history (as a bar graph):

You can enter this data manually in Nightcout Care Portal or with the "CarePortal" Pebble app. Alternatively, you can set up an OpenAPS uploader to upload it automatically.

Contributing

Contributions are welcome in the form of bugs and pull requests. To report a bug or provide feedback, please file an issue. To contribute code, please use the instructions below to build and test the watchface.

  • Install the Pebble SDK Tool.

  • Install and activate Pebble SDK 3.7. (For now, it is necessary to build the app with this older version of the SDK, since it is the latest version which can build pbw files for Pebble Time and Steel running firmware 2.9.1. In the near future, the app will be migrated to use the latest SDK, which will require users of those Pebbles to upgrade their firmware.)

    pebble sdk install 3.7
    pebble sdk activate 3.7
    
  • Build and run the watchface with a command like:

    pebble clean && pebble build && pebble install --emulator aplite && pebble logs
    
  • The watchface will ask for settings from the "phone." Open the configuration page with this command and hit "save" in your browser (you'll need to do this only once):

    pebble emu-app-config --emulator aplite
    
  • At some point you'll want to install your revisions on your watch. Flip the "Enable Developer Connections" switch in the Pebble app on your phone, then:

    pebble install --phone <phone ip address>
    

Tips:

  • Testing the configuration page: If you make changes to the configuration page, you must build the watchface to point to your local copy of the page (file:///...). To do this, set BUILD_ENV to development. (More info here.)

    BUILD_ENV=development pebble build
    pebble install --emulator aplite
    pebble emu-app-config --emulator aplite
    
  • Syntax checking: If you use Vim, I highly recommend using Syntastic to display syntax errors. On my OS X system running Pebble Tool v4.1.1, these lines make Syntastic aware of Pebble's header files and suppress warnings generated within those files:

    let g:syntastic_c_include_dirs = ['/Users/<user>/Library/Application Support/Pebble SDK/SDKs/3.7/sdk-core/pebble/aplite/include', 'build/aplite']
    let g:syntastic_c_remove_include_errors = 1
    
  • JavaScript errors: If you see a JavaScript error in the console, the line numbers will be reported relative to build/pebble-js-app.js, which is the concatenation of all files in src/js/**/*.js.

Testing

Since this software displays real-time health data, it is important to be able to verify that it works as expected. This project includes two tools to aid testing: a mock Nightscout server and automated screenshot testing. There is also a suite of JavaScript unit tests.

To install testing dependencies, use pip:

pip install -r requirements.txt
  • Mock Nightscout server

    The test/ directory includes a server which uses the Flask framework. To run it:

    MOCK_SERVER_PORT=5555 python test/server.py
    

    Then open the configuration page to set your Nightscout host to http://localhost:5555:

    pebble emu-app-config
    # ...make configuration changes in web browser...
    

    To set the data that will be returned by the sgv.json endpoint:

    vi sgv-data.json
    # ...edit mock data...
    curl -d @sgv-data.json http://localhost:5555/set-sgv
    

    Verify:

    curl http://localhost:5555/api/v1/entries/sgv.json
    
  • Automated screenshot testing

    Writing integration tests for Pebble is not simple. The best method I have found is to take screenshots. Each test case provides watchface configuration and SGV data to the mock server, triggers the emulator to open a configuration page hosted on the mock server, and does magic to pass the stored configuration back to the emulator. By design, receiving new configuration causes the watchface to request new data from the mock server. A screenshot can then be saved for that combination of configuration and data.

    To run tests:

    bash test/do_screenshots.sh
    

    This will build the watchface, run it in the emulator, take a screenshot for each test, and generate an HTML file with the results. To add a new test case, follow the examples in test/test_screenshots.py.

    Automated verification of the screenshots and CI are coming soon. For now, you manually inspect them.

  • JavaScript unit tests

    There is a suite of JavaScript unit tests to verify the transformation of Nightscout data in PebbleKit JS. These are run with Node + Mocha.

    cd test/js
    npm install
    npm test
    

To do:

  • High/low BG alerts
  • Stale data alerts
  • Show date when space allows
  • Color support for Pebble Time
  • A fixed layout which supports Pebble Time Round
  • Use data directly from Dexcom Share (no Nightscout site required)
  • Recency indicator (like Dexcom's warm-up pie chart)
  • Ability to view longer time scale
  • More dynamic sizing of content (e.g. bigger/smaller time and BG)
  • etc.

Disclaimer

This project is intended for educational and informational purposes only. It is not FDA approved and should not be used to make medical decisions. It is neither affiliated with nor endorsed by Dexcom.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 43.0%
  • C 32.8%
  • HTML 12.7%
  • Python 11.2%
  • Shell 0.3%