-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[SleepLog] Fix important bugs with HRM being undefined #4023
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
RKBoss6
wants to merge
11
commits into
espruino:master
Choose a base branch
from
RKBoss6:sleeplogbuxfix
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+24
−33
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
5e63154
Refactor health status logic in boot.js
RKBoss6 6fa7816
Update version number to 0.23 in metadata.json
RKBoss6 90e6ecf
Update ChangeLog for version 0.23
RKBoss6 375ca0b
Update heart rate monitoring logic in boot.js
RKBoss6 eff04d5
Merge branch 'espruino:master' into sleeplogbuxfix
RKBoss6 b64639d
Update ChangeLog
RKBoss6 53c3005
Update health log message for clarity
RKBoss6 050d58d
Clean up health function in boot.js
RKBoss6 463b1ef
Merge branch 'espruino:master' into sleeplogbuxfix
RKBoss6 4f109e7
Update ChangeLog
RKBoss6 9489c19
Change hrm step to 1 for finer tuning
RKBoss6 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -151,39 +151,29 @@ if (global.sleeplog.conf.enabled) { | |
// define health listener function | ||
// - called by event listener: "this"-reference points to global | ||
health: function(data) { | ||
print("Sleep Log - Health Data Acquired"); | ||
// check if global variable accessable | ||
if (!global.sleeplog) return new Error("sleeplog: Can't process health event, global object missing!"); | ||
|
||
// check if movement is available | ||
if (!data.movement) return; | ||
|
||
// add timestamp rounded to 10min, corrected to 10min ago | ||
data.timestamp = data.timestamp || ((Date.now() / 6E5 | 0) - 1) * 6E5; | ||
|
||
// add preliminary status depending on charging and movement thresholds | ||
// 1 = not worn, 2 = awake, 3 = light sleep, 4 = deep sleep | ||
if(data.hrm){ | ||
|
||
if (!Bangle.isCharging()) { | ||
if (data.heartRate <= global.sleeplog.conf.hrmDeepTh) { | ||
data.status = 4; // deep sleep | ||
} else if (data.heartRate <= global.sleeplog.conf.hrmLightTh) { | ||
data.status = 3; // light sleep | ||
} else { | ||
data.status = 2; // awake | ||
} | ||
} else { | ||
data.status = 1; // not worn | ||
} | ||
|
||
|
||
}else{ | ||
data.status = Bangle.isCharging() ? 1 : | ||
data.movement <= global.sleeplog.conf.deepTh ? 4 : | ||
data.movement <= global.sleeplog.conf.lightTh ? 3 : 2; | ||
if(data.bpm){ | ||
if (!Bangle.isCharging()) { | ||
if (data.bpm <= global.sleeplog.conf.hrmDeepTh) data.status = 4; | ||
else if (data.bpm <= global.sleeplog.conf.hrmLightTh) data.status = 3; | ||
else data.status = 2; | ||
} else data.status = 1; | ||
} else { | ||
if (!Bangle.isCharging()) { | ||
RKBoss6 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (data.movement <= global.sleeplog.conf.deepTh) data.status = 4; | ||
else if (data.movement <= global.sleeplog.conf.lightTh) data.status = 3; | ||
else data.status = 2; | ||
} else data.status = 1; | ||
} | ||
|
||
|
||
|
||
// check if changing to deep sleep from non sleeping | ||
if (data.status === 4 && global.sleeplog.status <= 2) { | ||
global.sleeplog.checkIsWearing((isWearing, data) => { | ||
|
@@ -303,7 +293,7 @@ if (global.sleeplog.conf.enabled) { | |
timestamp: new Date(data.timestamp), | ||
status: data.status, | ||
consecutive: data.consecutive, | ||
prevStatus: data.status === this.status ? undefined : this.status, | ||
prevStatus: this.status, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this change needed? I wonder if it could have some unintended side effect? |
||
prevConsecutive: data.consecutive === this.consecutive ? undefined : this.consecutive | ||
}, (e => {delete e.fn; return e;})(entry.clone())); | ||
}); | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.