Skip to content

Conversation

@RKBoss6
Copy link
Contributor

@RKBoss6 RKBoss6 commented Jan 25, 2026

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

RKBoss6 and others added 30 commits January 23, 2026 19:09
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.
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.
@RKBoss6
Copy link
Contributor Author

RKBoss6 commented Jan 27, 2026

I think this is good to go now

@RKBoss6 RKBoss6 marked this pull request as ready for review January 27, 2026 21:36
Co-authored-by: thyttan <97237430+thyttan@users.noreply.github.com>
@thyttan
Copy link
Collaborator

thyttan commented Jan 27, 2026

I'll try to get to this Thursday night but no promises 🙂

@RKBoss6
Copy link
Contributor Author

RKBoss6 commented Jan 27, 2026

No worries!!

@RKBoss6 RKBoss6 marked this pull request as draft January 30, 2026 02:51
@RKBoss6
Copy link
Contributor Author

RKBoss6 commented Jan 30, 2026

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!

@RKBoss6
Copy link
Contributor Author

RKBoss6 commented Feb 2, 2026

Alright, this is good to go at long last!! Thanks for being patient as I finalized the last few things, @thyttan!

@RKBoss6 RKBoss6 marked this pull request as ready for review February 2, 2026 21:23
@RKBoss6 RKBoss6 requested a review from thyttan February 3, 2026 02:18
@RKBoss6
Copy link
Contributor Author

RKBoss6 commented Feb 6, 2026

Any update on this?

@thyttan
Copy link
Collaborator

thyttan commented Feb 6, 2026

Ah! I can try it out now :)

@RKBoss6
Copy link
Contributor Author

RKBoss6 commented Feb 6, 2026

Sorry, I just put it on my app loader right now

Copy link
Collaborator

@thyttan thyttan left a 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.
Copy link
Collaborator

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?

Copy link
Contributor Author

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);
Copy link
Collaborator

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.

Copy link
Contributor Author

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...

Copy link
Collaborator

@thyttan thyttan Feb 10, 2026

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);
Copy link
Collaborator

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;
Copy link
Collaborator

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;
Copy link
Collaborator

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.

Copy link
Contributor Author

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants