1
0
Fork 0
BangleApps/apps/sleeplog
storm64 68abc30707
sleeplog: Update ChangeLog
Reorganizing entries to match build dependencies
2022-08-18 00:31:58 +02:00
..
ChangeLog sleeplog: Update ChangeLog 2022-08-18 00:31:58 +02:00
README.md [sleeplog] Change caching for global getStats 2022-05-26 11:27:36 +02:00
app-icon.js sleeplog: Add Sleep Log App 2022-02-11 09:29:02 +01:00
app.js [sleeplog] Add "View log" in debug + send via BT 2022-05-26 10:41:56 +02:00
app.png sleeplog: Add Sleep Log App 2022-02-11 09:29:02 +01:00
boot.js sleeplog: Update boot.js 2022-08-17 23:21:35 +02:00
conf_20x20.png [sleeplog] Replace old icons 2022-05-20 20:14:05 +02:00
debug_20x20.png [sleeplog] Replace old icons 2022-05-20 20:14:05 +02:00
file_20x20.png [sleeplog] Replace old icons 2022-05-20 20:14:05 +02:00
interface.html [sleeplog] Redesign interfacce.html 2022-05-24 23:13:03 +02:00
lib.js [sleeplog] Complete rework, BETA v01 2022-05-20 17:17:30 +02:00
metadata.json sleeplog: Update metadata.json 2022-08-17 23:24:34 +02:00
off_20x20.png [sleeplog] Replace old icons 2022-05-20 20:14:05 +02:00
screenshot1.png sleeplog: Update screenshots 2022-02-16 13:21:00 +01:00
screenshot2.png sleeplog: Update screenshots 2022-02-16 13:21:00 +01:00
screenshot3.png sleeplog: Update screenshots 2022-02-16 13:21:00 +01:00
settings.js [sleeplog] Add "View log" in debug + send via BT 2022-05-26 10:41:56 +02:00

README.md

Sleep Log

This app logs and displays the following states:

  • sleepling status: unknown, not worn, awake, light sleep, deep sleep
  • consecutive sleep status: unknown, not consecutive, consecutive

It is using the built in movement calculation to decide your sleeping state. While charging it is assumed that you are not wearing the watch and if the status changes to deep sleep the internal heartrate sensor is used to detect if you are wearing the watch.

-+-                       -+-
-+-     BETA Version      -+-
-+-                       -+-

Introduction


I am proud to present the new sleeplog app: version 0.10 🎉 🎊

Sorry that it took so long but hopefully most of the early bugs are sorted out and the app should be ready to be use and get tested!

I would love to hear about your impressions and like to know your choice of thresholds, to set the default values as optimized as possible.

The last piece of work is to rewrite the README.md to show how to use it and show the restrictions and possibilities. But here are some explanations how to use the app and settings:

  • On the app screen:

    • swipe left & right to change the displayed day
    • touch on the "title" (e.g. Night to Fri 20/05/2022) to enter a day selection prompt
    • touch on the info area (by default displaying consecutive and true sleeping) to change the displayed information
    • touch on the wrench (upper right corner) to enter the settings
    • exit the app with the UI back button widget on the upper left corner
  • Inside the settings:

    • the threshold values are accessible through a submenu
    • app timeout lets you specify a separate lockTimeout and backlightTimeout only for the sleeplog app
    • debug settings are available in a submenu down at the end:
      • display log is not implemented yet
      • options Enable and write File should be self explaining
      • the Duration specifies how long data should be written into the .csv file
      • the .csv file loggs the following data (timestamps are in days since 1900-01-01 00:00 UTC as used by office software):
        timestamp, movement, status, consecutive, asleepSince, awakeSince, bpm, bpmConfidence
  • Timestamps and files:

    1. externally visible/usable timestamps (in global.sleeplog) are formatted as Bangle timestamps:
      seconds since 1970-01-01 00:00 UTC
    2. internally used and logged (to sleeplog.log (StorageFile)) is within the highest available resolution:
      10 minutes since 1970-01-01 00:00 UTC (Bangle / (10 * 60 * 1000))
    3. debug .csv file ID (sleeplog_123456.csv) has a hourly resolution: hours since 1970-01-01 00:00 UTC (Bangle / (60 * 60 * 1000))
    4. logged timestamps inside the debug .csv file are formatted for office calculation software: days since 1900-01-01 00:00 UTC (Bangle / (24 * 60 * 60 * 1000) + 25569)
    5. every 14 days the sleeplog.log (StorageFile) is reduced and old entries are moved into separat files for each fortnight (sleeplog_1234.log) but still accessible though the app:
      fortnights since 1970-01-04 12:00 UTC (converted with require("sleeplog").msToFn(Bangle) and require("sleeplog").fnToMs(fortnight))
  • Logfiles from before 0.10:
    timestamps and sleeping status of old logfiles are automatically converted on your first consecutive sleep or manually by require("sleeplog").convertOldLog()

  • View logged data:
    if you'd like to view your logged data in the IDE, you can access it with require("sleeplog").printLog(since, until) or require("sleeplog").readLog(since, until) to view the raw data
    since & until in Bangle timestamp, e.g. require("sleeplog").printLog(Date()-24*60*60*1000, Date()) for the last 24h


Access statistics


  • Last Asleep Time [Date]:
    Date(sleeplog.awakeSince)
  • Last Awake Duration [ms]:
    Date() - sleeplog.awakeSince
  • Last Statistics [object]:
    // get stats of the last night (period as displayed inside the app)
    //  as this might be the mostly used function the data is cached inside the global object 
    sleeplog.getStats();
    
    // get stats of the last 24h
    require("sleeplog").getStats(0, 24*60*60*1000);
    // same as
    require("sleeplog").getStats(Date.now(), 24*60*60*1000);
    // output as object, timestamps as UNIX timestamp, durations in minutes
    ={ calculatedAt: 1653123553810, deepSleep: 250, lightSleep: 150, awakeSleep: 10,
      consecSleep: 320, awakeTime: 1030, notWornTime: 0, unknownTime: 0, logDuration: 1440,
      firstDate: 1653036600000, lastDate: 1653111600000 }
    
    // to get the start of a period defined by "Break TOD" of any date
    var startOfBreak = require("sleeplog").getLastBreak();
    // same as
    var startOfBreak = require("sleeplog").getLastBreak(Date.now());
    // output as date
    =Date: Sat May 21 2022 12:00:00 GMT+0200
    
    // get stats of this period as displayed inside the app
    require("sleeplog").getStats(require("sleeplog").getLastBreak(), 24*60*60*1000);
    // or any other day
    require("sleeplog").getStats(require("sleeplog").getLastBreak(Date(2022,4,10)), 24*60*60*1000);
    
  • Total Statistics [object]:
    // use with caution, may take a long time !
    require("sleeplog").getStats(0, 0, require("sleeplog").readLog());
    

Worth Mentioning


To do list

  • Edit/complete README.md.
  • Update screenshots.
  • Add more functionallities to interface.html.
  • Enable recieving data on the Gadgetbridge side + testing.

Requests, Bugs and Feedback

Please leave requests and bug reports by raising an issue at github.com/storm64/BangleApps (or send me a mail).

Creator

Storm64 (Mail, github)

Contributors

myxor (github)

Attributions

The app icon is downloaded from https://icons8.com.

License

MIT License


Temporarily removed logfiles from metadata.json to prevent removal on un-/reinstall:

"data": [
  {"name": "sleeplog.log", "storageFile": true},
  {"wildcard": "sleeplog_????.log"},
  {"wildcard": "sleeplog_??????.csv"}
],