baldav/src/bmr.js
4aiman b26264538b GPS point ordering + GPX export + chart zoom fixes
GPS background recording:
- Batched writes (10s flush) in native service
- Polling lock prevents parallel processing
- Track by timestamp instead of line count
- Recovery idempotent via max DB timestamp
- Seq numbers on live recorded points

GPX export:
- Button in session detail
- SAF file picker on Android (ACTION_CREATE_DOCUMENT)
- GPS config in metadata (accuracy, minSpeed, minDist)

Charts:
- Pinch zoom enabled at creation (Hammer.js registers handlers)
- touch-action: pan-y blocks pinch in normal view (page scrolls)
- Fullscreen: CSS-only expand (no canvas manipulation)
- Downsampled to 500 points for smooth rendering
- Back gesture collapses fullscreen before closing modal

Build: --real flag finds first non-emulator device
2026-05-16 21:21:13 +03:00

14 lines
548 B
JavaScript

// Mifflin-St Jeor equation for Basal Metabolic Rate
// Most accurate BMR formula validated by research (Mifflin et al., 1990)
//
// Males: BMR = 10 * weight(kg) + 6.25 * height(cm) - 5 * age(years) - 5
// Females: BMR = 10 * weight(kg) + 6.25 * height(cm) - 5 * age(years) + 161
export function calculateBmr(weightKg, heightCm, age, sex) {
const base = 10 * weightKg + 6.25 * heightCm - 5 * age;
return Math.round(sex === "m" ? base - 5 : base + 161);
}
export function getAge(birthYear) {
return new Date().getFullYear() - birthYear;
}