-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Create Calorie Tracking app w/ health integration #4142
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
base: master
Are you sure you want to change the base?
Conversation
Add metadata for Calorie Tracker application
Expanded the README to include the calorie calculation formula and its components, enhancing user understanding of the app's functionality.
…date boot.js to match
…nshot for health, add gender for myprofile
Refactor logic for setting resting heart rate and round max heart rate calculation.
Added instructions for taking Resting Heart Rate (RHR) measurements, including tips for optimal conditions and app navigation.
…nto caloriesApp
…nto caloriesApp
Removed the second screenshot from the metadata.
|
I think this is good to go now |
Co-authored-by: thyttan <97237430+thyttan@users.noreply.github.com>
|
I'll try to get to this Thursday night but no promises 🙂 |
|
No worries!! |
|
Hey - sorry about the delay. I'm testing a (hopefully) much more accurate formula that involves the MaxHr, minHr and Resting Hr, as well as age-specific formulas, so I've put it into draft for now, until that's sorted out. Thanks for sticking by while I iron out a few more kinks in the app! |
Updated README to clarify ClockInfo and health integration details.
|
Alright, this is good to go at long last!! Thanks for being patient as I finalized the last few things, @thyttan! |
|
Any update on this? |
|
Ah! I can try it out now :) |
|
Sorry, I just put it on my app loader right now |
thyttan
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Here's my initial review :)
| require("Storage").readJSON("myprofile.json",1)); | ||
| ``` | ||
|
|
||
| * **require("calories").calcBMR**: Takes in myProfile data, and returns a bmr rate (calories/minute) from that data. The rate is unrounded for accuracy, so you must handle rounding accordingly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This and some other lines are very long and trigger horizontal scrolling in the app loader readme pop up. Can it be made to wrap instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not that I know of, because each README formatter is different. I've tried shortening the longer lines, can you let me know if the problem (mostly) goes away?
| /*LANG*/"< Back": () => back(), | ||
|
|
||
| /*LANG*/"My Profile": function(){ | ||
| eval(require("Storage").read("myprofile.settings.js"))(back); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't assume myprofile is installed since it's not a dependency of health app.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch - is there a way to test if an app is installed? We could read the myprofile JSON, but if the user hasn't opened the settings before, it'll flag as empty/nonexistent...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, why add it here at all? myprofile settings are accessible like other settings under "settings" - >"apps", right? Please take it out of this PR and do a separate PR for this addition - if you feel strongly about it 🙏
| @@ -0,0 +1,127 @@ | |||
| // Takes object with bpm, movement (in duration), steps (in duration), and duration in minutes | |||
| let calcAge=function(rawBday){ | |||
| let birth = new Date(rawBday); | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get this error, probably because I have not done any setup in the myprofile app?:
Uncaught TypeError: Variables of type undefined are not supported in date constructor
at calcAge (calories:2:41)
let birth=new Date(rawBday);let now=new Date();let diffInDays=(now-birth)/8...
^
at calcBMR (calories:3:93)
...=calcAge(myProfile.birthday);if(age<18){if(myProfile.gender!=undefined&&...
^
at intermittentBMRUpdate (.boot0:30:140)
...calModule.calcBMR(myProfile)*((now-lastBMRWrite)/60000));cal...
^
at .boot0 (.boot0:32:512)
...()});intermittentBMRUpdate();;
^
If so we should make this not happen some way. Either by using some default value somewhere or something. Not sure what's the best solution.
| // returns cals/minute | ||
| exports.calcBMR=function(myProfile){ | ||
| let bmr=0; | ||
| let weight = myProfile.weight; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get this error, probably since I haven't added any info to myprofile. Either we try to make sure the user have already entered info there. Or we nudge the user to add their weight. And/or add some default average value. What do you think?
>
{"t":"act","stp":0,"hrm":0,"mov":175,"act":"UNKNOWN"}
Uncaught Error: Calories: Not enough myProfile data to calculate!
at calcCalories (calories:10:234)
...yProfile data to calculate!);}let weight=myProfile.weight;let age=...
^
at .boot0:32:13
}),myProfile)if(!cd)return;calData.activeCaloriesBurned+=cd.activeC...
^
| }); | ||
| }; | ||
|
|
||
| menu[/*LANG*/`Resting HR: ${myprofile.restingHrm?myprofile.restingHrm:"--"}`]=RHRReading; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how best to handle but just looking in the settings page it looks weird having a "HR min" entry and a "Resting HR" entry. Even more so when they don't show the same number.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be better if we do the full names like Minimum HR, Resting HR, Maximum HR?
This is just a draft right now, but creates an app for calorie tracking based on #4092, that counts calories burned in a day and splits it by BMR, Active, and total calories. Uses MyProfile to get user health data, and hooks onto health events for new data. Also modifies myprofile to use RHR readings as an additional piece of data, with its own measurement UI.
Check it out at my app loader