Skip to content

Bender1061/urchin-cgm

 
 

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

In the Pebble app on your phone, open the "Settings" screen to set your Nightscout URL.

Layout

The layout is one of the most Ridiculously Configurable aspects of Urchin. The settings page includes a handful of pre-set layouts to get you started:

Use one as a starting point to build your own watchface: reorder the elements, change heights and colors, toggle borders, move the icons...

Graph

Set the bounds and target range of the graph on your phone.

You can choose the shape and size of the points on the graph so that the glucose history is as long or as short as you want. To show up to 12 hours of BGs, plot the points super-thin or overlapping. For a "sparkline" view of the last hour, plot bigger points with more space in between.

Status bar content

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

  • Date - in whatever format you want. (e.g. Sat Oct 7)
  • 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. (19) 1.5U/h +0.6)
  • Insulin on board - this can be calculated from treatments entered manually in Nightscout Care Portal, or reported automatically from MiniMed Connect, Loop, or OpenAPS. (e.g. 2.3 U)
  • Insulin + carbs on board - same IOB as above plus carbs-on-board entered in Care Portal. (e.g. 2.3 U 31 g)
  • Loop status - status from the Loop iOS app -- predicted BG, IOB, COB, current temp basal, pump battery, phone battery -- in whatever format you want. (e.g. 143 0.2U 13g 1.50, or 1.50U/h 0.2 U 13 g | 1.57v 83%)
  • IOB and temp - OpenAPS - IOB and currently-active temp basal rate from the most recent OpenAPS status upload, or if the most recent status indicates failure, the time since that failure plus the time and IOB from the last successful status. (e.g. (2) 1.1U 1.9x13 or (4) -- | (+23) 2.2U)
  • 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.
  • Multiple - Up to 3 of the above, one on each line.

The recency indicator in the status bar is configurable. You can choose the format ((3), 3:, etc.) and the conditions under which it is shown (for example, "don't show the recency as long as it's fewer than 10 minutes old," or "don't show the status at all when it's more than 30 minutes old")

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):

To enter pump data manually, you can use Nightcout Care Portal or the "CarePortal" Pebble app.

To upload pump data automatically, you can use RileyLink or Loop on iOS, or build an OpenAPS uploader.

What do the icons mean?

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.

When the watch fails to fetch data, a message describing the problem briefly appears in the graph.

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 the Pebble SDK. As of this writing, the app is built with SDK 3.14, but later versions should work, too.

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

    pebble build && pebble install --emulator basalt && 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 basalt
    
  • 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 basalt
    pebble emu-app-config --emulator basalt
    
  • 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/current/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.

The most effective method of integration testing I've found is to compare screenshots. This relies on ImageMagick to compute diffs. Screenshot tests and JavaScript unit tests are run automatically by CircleCI.

  • Running screenshot tests locally

    Install ImageMagick, then use pip to install Python testing dependencies:

    pip install -r requirements.txt --user
    

    Run the tests:

    . test/do_screenshots.sh
    
  • Running an individual screenshot test

    . test/do_screenshots.sh -k TestName
    
  • Using the mock Nightscout server

    Start the server:

    MOCK_SERVER_PORT=5555 python test/server.py
    

    Build the watchface as usual:

    pebble build && pebble install --emulator basalt && pebble logs
    

    Use an editor to save mock data, send it to the server, verify it:

    vi sgv-data.json
    # ...edit mock data...
    
    # POST it for the server to store
    curl -d @sgv-data.json http://localhost:5555/set-sgv
    
    # Verify:
    curl http://localhost:5555/api/v1/entries/sgv.json
    
    # ("sgv" can be sgv, entries, treatments, devicestatus, or profile)
    

    Use the browser to configure the watchface:

    # Make sure you set the Nightscout host to "http://localhost:5555"
    pebble emu-app-config --emulator basalt
    
  • Running JavaScript unit tests locally

    These require Node. See the Mocha and Expect docs.

    cd test/js
    npm install
    npm test
    

To do:

  • High/low BG alerts
  • Stale data alerts
  • More color configurability
  • A fixed layout which supports Pebble Time Round
  • Use data directly from Dexcom Share (no Nightscout site required)
  • 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

A graph of your CGM data on a Pebble watch.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 43.2%
  • C 27.6%
  • Python 14.5%
  • HTML 13.7%
  • Shell 1.0%