//This app is an extra feature implementation for the Run.app of the bangle.js. It's called run+
//The calculation of the Heart Rate Zones is based on the Karvonnen method. It requires to know maximum and minimum heart rates. More precise calculation methods require a lab.
//Other methods are even more approximative.
wu.hide();
letR=Bangle.appRect;
g.reset().clearRect(R);
g.drawLine(40,64,88,52,136,64);
g.drawLine(88,52,136,64);
g.drawLine(40,112,88,124);
g.drawLine(88,124,132,112);
g.setFont("Vector",20);
//To calculate Heart rate zones, we need to know the heart rate reserve (HRR)
// HRR = maximum HR - Minimum HR. minhr is minimum hr, maxhr is maximum hr.
//get the hrr (heart rate reserve).
// I put random data here, but this has to come as a menu in the settings section so that users can change it.
//Test input to verify the zones work. The following value for "hr" has to be deleted and replaced with the Heart Rate Monitor input.
lethr=174;
lethr1=hr;
// These letiables display next and previous HR zone.
//get the hrzones right. The calculation of the Heart rate zones here is based on the Karvonnen method
//60-70% of HRR+minHR = zone2. //70-80% of HRR+minHR = zone3. //80-90% of HRR+minHR = zone4. //90-99% of HRR+minHR = zone5. //=>99% of HRR+minHR = serious risk of heart attack
letminzone2=hrr*0.6+minhr;
letmaxzone2=hrr*0.7+minhr;
letmaxzone3=hrr*0.8+minhr;
letmaxzone4=hrr*0.9+minhr;
letmaxzone5=hrr*0.99+minhr;
// HR data: large, readable, in the middle of the screen
g.setFont("Vector",50);
g.drawString(hr1,62,66);
//These functions call arcs to show different HR zones.
//To shorten the code, I'll reference some letiables and reuse them.
letcentreX=R.x+0.5*R.w;//g.getWidth();
letcentreY=R.y+0.5*R.h;//g.getWidth();
letminRadius=0.38*R.h;//g.getWidth();
letmaxRadius=0.50*R.h;//g.getWidth();
//####### A function to simplify a bit the code ######
//Subdivided zones for better readability of zones when calling the images. //Changing HR zones will trigger the function with the image and previous&next HR zones.